From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 14 Aug 2008 12:43:48 -0500 From: Scott Wood To: Kumar Gala Subject: Re: [PATCH v3] libfdt: Add support for using aliases in fdt_path_offset() Message-ID: <20080814174348.GA19488@ld0162-tx32.am.freescale.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: Cc: linuxppc-dev@ozlabs.org, devicetree-discuss@ozlabs.org, David Gibson List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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