From: Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
To: David Gibson
<david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>,
Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>,
devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
Subject: [PATCH 2/5] libfdt: overlay: Check the value of the right variable
Date: Sat, 4 Mar 2017 14:26:44 +0100 [thread overview]
Message-ID: <20170304132647.23286-2-nicolas.iooss_linux@m4x.org> (raw)
In-Reply-To: <20170304132647.23286-1-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
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-oWGTIYur0i8@public.gmane.org>
---
libfdt/fdt_overlay.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
--
2.11.1
next prev parent reply other threads:[~2017-03-04 13:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-04 13:26 [PATCH 1/5] dtc: Simplify asm_emit_string() implementation Nicolas Iooss
[not found] ` <20170304132647.23286-1-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-04 13:26 ` Nicolas Iooss [this message]
[not found] ` <20170304132647.23286-2-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01 ` [PATCH 2/5] libfdt: overlay: Check the value of the right variable Simon Glass
[not found] ` <CAPnjgZ2Lon3e-NV-FH76QpXFP2tAcc=Ex48hG7OMQxbcjzBfig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-09 1:35 ` David Gibson
2017-03-04 13:26 ` [PATCH 3/5] tests: Make realloc_fdt() really allocate *fdt Nicolas Iooss
[not found] ` <20170304132647.23286-3-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01 ` Simon Glass
[not found] ` <CAPnjgZ0=jfYeYZSZUeQRf00wyHaQwDBRYvqAQqO6Bu0B2VA5NA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-09 1:35 ` David Gibson
2017-03-04 13:26 ` [PATCH 4/5] fdtget: Use @return to document the return value Nicolas Iooss
[not found] ` <20170304132647.23286-4-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01 ` Simon Glass
2017-03-04 13:26 ` [PATCH 5/5] fdtput: Remove star from value_len documentation Nicolas Iooss
[not found] ` <20170304132647.23286-5-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2017-03-08 21:01 ` Simon Glass
2017-03-06 4:13 ` [PATCH 1/5] dtc: Simplify asm_emit_string() implementation David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170304132647.23286-2-nicolas.iooss_linux@m4x.org \
--to=nicolas.iooss_linux-owgtiyur0i8@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jdl-CYoMK+44s/E@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).