On Wed, Mar 08, 2017 at 02:01:44PM -0700, Simon Glass wrote: > On 4 March 2017 at 06:26, Nicolas Iooss <nicolas.iooss_linux@xxxxxxx> wrote: > > overlay_update_local_node_references() saves the result of > > fdt_subnode_offset() into variable tree_child but checks for variable > > ret afterwards. As this does not make sense, check tree_child instead of > > ret. > > > > This bug has been found by compiling with clang. The compiler reported > > the following warning: > > > > libfdt/fdt_overlay.c:275:7: error: variable 'ret' may be > > uninitialized when used here > > [-Werror,-Wconditional-uninitialized] > > if (ret == -FDT_ERR_NOTFOUND) > > ^~~ > > libfdt/fdt_overlay.c:210:9: note: initialize the variable 'ret' to > > silence this > > warning > > int ret; > > ^ > > = 0 > > > > Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@xxxxxxx> > > --- > > libfdt/fdt_overlay.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx> > > This suggests we need a new test case. True. I've already merged this but adding a testcase as a followup would be most appreciated. > > > > > diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c > > index 56cb70ed4445..b2fb5d970ccc 100644 > > --- a/libfdt/fdt_overlay.c > > +++ b/libfdt/fdt_overlay.c > > @@ -272,7 +272,7 @@ static int overlay_update_local_node_references(void *fdto, > > > > tree_child = fdt_subnode_offset(fdto, tree_node, > > fixup_child_name); > > - if (ret == -FDT_ERR_NOTFOUND) > > + if (tree_child == -FDT_ERR_NOTFOUND) > > return -FDT_ERR_BADOVERLAY; > > if (tree_child < 0) > > return tree_child; > > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature