summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Roth <martinroth@google.com>2017-12-15 10:18:57 -0700
committerMartin Roth <martinroth@google.com>2017-12-20 16:35:13 +0000
commitf183a85932246dee7c6a1a78d7c944c46c123450 (patch)
tree153fcf41ffd4df941a0c933efa412e21aac4754c
parentec2e61ab2fb0a3093571ec034b182e073a2ba6c3 (diff)
downloadcoreboot-f183a85932246dee7c6a1a78d7c944c46c123450.tar.gz
coreboot-f183a85932246dee7c6a1a78d7c944c46c123450.tar.bz2
coreboot-f183a85932246dee7c6a1a78d7c944c46c123450.zip
util/cbfstool: Check for NULL before dereference
Fixed coverity issue: 1302455 - Dereference null return value Change-Id: I59b908adc4d35f08fda8e4ad3f806714f2caeb65 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/22900 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
-rw-r--r--util/cbfstool/partitioned_file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/cbfstool/partitioned_file.c b/util/cbfstool/partitioned_file.c
index 7b4b0035f67e..9abd32aab6f1 100644
--- a/util/cbfstool/partitioned_file.c
+++ b/util/cbfstool/partitioned_file.c
@@ -196,6 +196,10 @@ partitioned_file_t *partitioned_file_reopen(const char *filename,
const struct fmap_area *fmap_fmap_entry =
fmap_find_area(file->fmap, SECTION_NAME_FMAP);
+
+ if (!fmap_fmap_entry)
+ return NULL;
+
if ((long)fmap_fmap_entry->offset != fmap_region_offset) {
ERROR("FMAP's '%s' section doesn't point back to FMAP start (did something corrupt this file?)\n",
SECTION_NAME_FMAP);