public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Mitch Bradley <wmb@firmworks•com>
To: Scott Wood <scottwood@freescale•com>,
	Kumar Gala <galak@kernel•crashing.org>,
	linuxppc-dev@ozlabs•org, devicetree-discuss@ozlabs•org
Subject: Re: [PATCH v3] libfdt: Add support for using aliases in	fdt_path_offset()
Date: Thu, 14 Aug 2008 15:51:05 -1000	[thread overview]
Message-ID: <48A4E109.2020506@firmworks.com> (raw)
In-Reply-To: <20080815013439.GB12327@yookeroo.seuss>



David Gibson wrote:
> On Thu, Aug 14, 2008 at 12:43:48PM -0500, Scott Wood wrote:
>   
>> On Thu, Aug 14, 2008 at 08:28:19AM -0500, Kumar Gala wrote:
>>     
>>> -	if (*path != '/')
>>> -		return -FDT_ERR_BADPATH;
>>> +	/* see if we have an alias */
>>> +	if (*path != '/') {
>>> +		const char *q;
>>> +		int aliasoffset = fdt_path_offset(fdt, "/aliases");
>>> +
>>> +		if (aliasoffset < 0)
>>> +			return -FDT_ERR_BADPATH;
>>> +
>>> +		q = strchr(path, '/');
>>> +		if (!q)
>>> +			q = end;
>>> +
>>> +		p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
>>> +		if (!p)
>>> +			return -FDT_ERR_BADPATH;
>>> +		offset = fdt_path_offset(fdt, p);
>>> +
>>> +		p = q;
>>> +	}
>>>       
>> Can we limit the recursion depth to avoid falling off the stack if an
>> alias points to itself?  Or if aliases pointing to aliases are
>> disallowed, check for a leading '/' before recursively calling
>> fdt_path_offset.
>>     
>
> Hmm.. my reading of 1275 says that an alias pointing to another alias
> is not permitted, but I'm not terribly confident I'm not misreading
> it.  Segher, do you know whether this is allowed?
>   

The 1275 spec doesn't require multiple levels of aliasing, but my 
current implementation allows it and uses it for things like components 
of the network stack.


> If that's the case then, yes, we should not recurse if the alias value
> doesn't start with a /.  In fact, if I factor out a fdt_get_alias()
> function, it should probably check the alias and return an error if
> it's not an absolute path.
>
>   

  reply	other threads:[~2008-08-15  1:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14 13:28 [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset() Kumar Gala
2008-08-14 13:36 ` David Gibson
2008-08-14 15:24 ` Jon Loeliger
2008-08-14 17:43 ` Scott Wood
2008-08-15  1:34   ` David Gibson
2008-08-15  1:51     ` Mitch Bradley [this message]
2008-08-16  6:51     ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48A4E109.2020506@firmworks.com \
    --to=wmb@firmworks$(echo .)com \
    --cc=devicetree-discuss@ozlabs$(echo .)org \
    --cc=galak@kernel$(echo .)crashing.org \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=scottwood@freescale$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox