Devicetree
 help / color / mirror / Atom feed
From: Scott Wood <scottwood-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
To: Kumar Gala <galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org,
	devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset()
Date: Thu, 14 Aug 2008 12:43:48 -0500	[thread overview]
Message-ID: <20080814174348.GA19488@ld0162-tx32.am.freescale.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0808140827220.2701-S0ohy4nlquecPGwCZ8RIISaugJOa9f/+@public.gmane.org>

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.

-Scott

  parent reply	other threads:[~2008-08-14 17:43 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
     [not found] ` <Pine.LNX.4.64.0808140827220.2701-S0ohy4nlquecPGwCZ8RIISaugJOa9f/+@public.gmane.org>
2008-08-14 13:36   ` David Gibson
2008-08-14 15:24   ` Jon Loeliger
2008-08-14 17:43   ` Scott Wood [this message]
     [not found]     ` <20080814174348.GA19488-VKaLA/mbEU932VTgPCOETVjVikpgYyvb5NbjCUgZEJk@public.gmane.org>
2008-08-15  1:34       ` David Gibson
2008-08-15  1:51         ` Mitch Bradley
     [not found]         ` <20080815013439.GB12327-787xzQ0H9iRg7VrjXcPTGA@public.gmane.org>
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=20080814174348.GA19488@ld0162-tx32.am.freescale.net \
    --to=scottwood-kzfg59tc24xl57midrcfdg@public.gmane.org \
    --cc=devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    --cc=galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
    --cc=linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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