[PATCH] ARM: zImage: atags_to_fdt: Fix node names on added root nodes

Chris Packham Chris.Packham at alliedtelesis.co.nz
Mon Jan 25 21:50:12 EST 2021


Hi Rob,

On 26/01/21 3:39 pm, Rob Herring wrote:
> Commit 7536c7e03e74 ("of/fdt: Remove redundant kbasename function
> call") exposed a bug creating DT nodes in the ATAGS to DT fixup code.
> Non-existent nodes would mistaken get created with a leading '/'. The
> problem was fdt_path_offset() takes a full path while creating a node
> with fdt_add_subnode() takes just the basename.
>
> Since this we only add root child nodes, we can just skip over the '/'.
>
> Fixes: 7536c7e03e74 ("of/fdt: Remove redundant kbasename function call")
> Reported-by: Chris Packham <chris.packham at alliedtelesis.co.nz>
> Cc: Qi Zheng <arch0.zheng at gmail.com>
> Cc: Russell King <linux at armlinux.org.uk>
> Signed-off-by: Rob Herring <robh at kernel.org>

Thanks for the quick patch. It doesn't quite seem to work as my system 
can't find it's initrd (it can with my other hacky patch). It does seem 
to get the command line info as I'm getting printk output.

> ---
>   arch/arm/boot/compressed/atags_to_fdt.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
> index 8452753efebe..31927d2fe297 100644
> --- a/arch/arm/boot/compressed/atags_to_fdt.c
> +++ b/arch/arm/boot/compressed/atags_to_fdt.c
> @@ -15,7 +15,8 @@ static int node_offset(void *fdt, const char *node_path)
>   {
>   	int offset = fdt_path_offset(fdt, node_path);
>   	if (offset == -FDT_ERR_NOTFOUND)
> -		offset = fdt_add_subnode(fdt, 0, node_path);
> +		/* Add the node to root if not found, dropping the leading '/' */
> +		offset = fdt_add_subnode(fdt, 0, node_path + 1);
>   	return offset;
>   }
>   


More information about the linux-arm-kernel mailing list