Skip to contentSkip to conversation

fdt: Check for NULL return from fdt_getprop in 'fdt set'

PATCH New Tom Rini 3 participants 3 messages Jun 13, 2017 – Jul 6, 2017

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 fdt: Check for NULL return from fdt_getprop in 'fdt set'

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 <[email protected]>
Reported-by: Coverity (CID: 163249)
Fixes 72c98ed1ab48 ("fdt: Add a check to do_fdt() for coverity")

---
 cmd/fdt.c | 4 ++++
 1 file changed, 4 insertions(+)
cmd/fdt.c +4 -0
index 31a536198c8e..05e19f8a72bf 100644
@@ -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);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 fdt: Check for NULL return from fdt_getprop in 'fdt set'

Quoted 11 lines · Tom Rini

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 <[email protected]>
Reported-by: Coverity (CID: 163249)
Fixes 72c98ed1ab48 ("fdt: Add a check to do_fdt() for coverity")

---
 cmd/fdt.c | 4 ++++
 1 file changed, 4 insertions(+)
#2 lore raw

PATCH 1/1 fdt: Check for NULL return from fdt_getprop in 'fdt set'

Quoted 11 lines · Tom Rini

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 <[email protected]>
Reported-by: Coverity (CID: 163249)
Fixes 72c98ed1ab48 ("fdt: Add a check to do_fdt() for coverity")

---
 cmd/fdt.c | 4 ++++
 1 file changed, 4 insertions(+)

Applied to u-boot-dm, thanks!