diff mbox

[U-Boot] fdt: Check for NULL return from fdt_getprop in 'fdt set'

Message ID 1497352235-18368-1-git-send-email-trini@konsulko.com
State Accepted
Commit 99bb38e2cce9d99238458e0f6d1880c6d2e80a4d
Delegated to: Simon Glass
Headers show

Commit Message

Tom Rini June 13, 2017, 11:10 a.m. UTC
While the previous pass through fixed one place where we knew that
fdt_getprop would be given a positive len, in the case of 'fdt set' we
do not, so check that we did no get NULL from fdt_getprop().

Cc: Simon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 163249)
Fixes 72c98ed1ab48 ("fdt: Add a check to do_fdt() for coverity")
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 cmd/fdt.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Simon Glass June 17, 2017, 3:42 a.m. UTC | #1
On 13 June 2017 at 05:10, Tom Rini <trini@konsulko.com> wrote:
> While the previous pass through fixed one place where we knew that
> fdt_getprop would be given a positive len, in the case of 'fdt set' we
> do not, so check that we did no get NULL from fdt_getprop().
>
> Cc: Simon Glass <sjg@chromium.org>
> Reported-by: Coverity (CID: 163249)
> Fixes 72c98ed1ab48 ("fdt: Add a check to do_fdt() for coverity")
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>  cmd/fdt.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass July 6, 2017, 5:36 p.m. UTC | #2
On 13 June 2017 at 05:10, Tom Rini <trini@konsulko.com> wrote:
> While the previous pass through fixed one place where we knew that
> fdt_getprop would be given a positive len, in the case of 'fdt set' we
> do not, so check that we did no get NULL from fdt_getprop().
>
> Cc: Simon Glass <sjg@chromium.org>
> Reported-by: Coverity (CID: 163249)
> Fixes 72c98ed1ab48 ("fdt: Add a check to do_fdt() for coverity")
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>  cmd/fdt.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 31a536198c8e..05e19f8a72bf 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -284,6 +284,10 @@  static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			len = 0;
 		} else {
 			ptmp = fdt_getprop(working_fdt, nodeoffset, prop, &len);
+			if (!ptmp) {
+				printf("prop (%s) not found!\n", prop);
+				return 1;
+			}
 			if (len > SCRATCHPAD) {
 				printf("prop (%d) doesn't fit in scratchpad!\n",
 				       len);