Skip to content

Commit

Permalink
powerpc: Fix bug in kernel copy of libfdt's fdt_subnode_offset_namelen()
Browse files Browse the repository at this point in the history
There's currently an off-by-one bug in fdt_subnode_offset_namelen()
which causes it to keep searching after it's finished the subnodes of
the given parent, and into the subnodes of siblings of the original
node which come after it in the tree.  This bug was introduced in
commit ed95d74 ("powerpc: Update
in-kernel dtc and libfdt to version 1.2.0").

A patch has already been submitted to dtc/libfdt mainline.  We don't
really want to pull in a new upstream version during the 2.6.28 cycle,
but we should still fix this bug, hence this standalone version of the
fix for the in-kernel libfdt.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
David Gibson authored and Paul Mackerras committed Oct 31, 2008
1 parent 210434d commit 2dccbf4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/powerpc/boot/libfdt/fdt_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,

FDT_CHECK_HEADER(fdt);

for (depth = 0;
offset >= 0;
for (depth = 0, offset = fdt_next_node(fdt, offset, &depth);
(offset >= 0) && (depth > 0);
offset = fdt_next_node(fdt, offset, &depth)) {
if (depth < 0)
return -FDT_ERR_NOTFOUND;
Expand All @@ -114,7 +114,10 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
return offset;
}

return offset; /* error */
if (offset < 0)
return offset; /* error */
else
return -FDT_ERR_NOTFOUND;
}

int fdt_subnode_offset(const void *fdt, int parentoffset,
Expand Down

0 comments on commit 2dccbf4

Please sign in to comment.