summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-06-07 16:28:40 (GMT)
committerTom Rini <trini@konsulko.com>2017-06-12 12:38:07 (GMT)
commit96725153197f32e00a07d0fe1bfbab8662d94cb9 (patch)
treeeda6c61285b08acb6677c3cf0e2d92a5fe47de72 /tools
parent66a1b30d14566676293ba4010a0d592adc61ce95 (diff)
downloadu-boot-96725153197f32e00a07d0fe1bfbab8662d94cb9.tar.xz
fdtgrep: Deal with NULL data passed to check_type_include()
Since the parameter can be NULL we must be careful not to dereference it in this case. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Coverity (CID: 163250) Fixes: 1043d0a0 (fdt: Add fdtgrep tool)
Diffstat (limited to 'tools')
-rw-r--r--tools/fdtgrep.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/tools/fdtgrep.c b/tools/fdtgrep.c
index e373c43..f51f5f1 100644
--- a/tools/fdtgrep.c
+++ b/tools/fdtgrep.c
@@ -522,18 +522,21 @@ static int check_type_include(void *priv, int type, const char *data, int size)
* return 1 at the first match. For exclusive conditions, we must
* check that there are no matches.
*/
- for (val = disp->value_head; val; val = val->next) {
- if (!(type & val->type))
- continue;
- match = fdt_stringlist_contains(data, size, val->string);
- debug(" - val->type=%x, str='%s', match=%d\n",
- val->type, val->string, match);
- if (match && val->include) {
- debug(" - match inc %s\n", val->string);
- return 1;
+ if (data) {
+ for (val = disp->value_head; val; val = val->next) {
+ if (!(type & val->type))
+ continue;
+ match = fdt_stringlist_contains(data, size,
+ val->string);
+ debug(" - val->type=%x, str='%s', match=%d\n",
+ val->type, val->string, match);
+ if (match && val->include) {
+ debug(" - match inc %s\n", val->string);
+ return 1;
+ }
+ if (match)
+ none_match &= ~val->type;
}
- if (match)
- none_match &= ~val->type;
}
/*