]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
libfdt: Fix NOP handling bug in fdt_add_subnode_namelen()
authorDavid Gibson <david@gibson.dropbear.id.au>
Thu, 14 Feb 2008 05:50:34 +0000 (16:50 +1100)
committerGerald Van Baren <vanbaren@cideas.com>
Wed, 19 Mar 2008 01:03:45 +0000 (21:03 -0400)
fdt_add_subnode_namelen() has a bug if asked to add a subnode to a
node which has NOP tags interspersed with its properties.  In this
case fdt_add_subnode_namelen() will put the new subnode before the
first NOP tag, even if there are properties after it, which will
result in an invalid blob.

This patch fixes the bug, and adds a testcase for it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
libfdt/fdt_rw.c

index a1c70ff154e3dce4866036e407c3757eb766928c..ac5019560fe02f58af5d895a42b7c776d20f5d0b 100644 (file)
@@ -333,7 +333,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
        do {
                offset = nextoffset;
                tag = fdt_next_tag(fdt, offset, &nextoffset);
-       } while (tag == FDT_PROP);
+       } while ((tag == FDT_PROP) || (tag == FDT_NOP));
 
        nh = _fdt_offset_ptr_w(fdt, offset);
        nodelen = sizeof(*nh) + ALIGN(namelen+1, FDT_TAGSIZE) + FDT_TAGSIZE;