From f183a85932246dee7c6a1a78d7c944c46c123450 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Fri, 15 Dec 2017 10:18:57 -0700 Subject: [PATCH] util/cbfstool: Check for NULL before dereference Fixed coverity issue: 1302455 - Dereference null return value Change-Id: I59b908adc4d35f08fda8e4ad3f806714f2caeb65 Signed-off-by: Martin Roth Reviewed-on: https://review.coreboot.org/22900 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- util/cbfstool/partitioned_file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/cbfstool/partitioned_file.c b/util/cbfstool/partitioned_file.c index 7b4b0035f6..9abd32aab6 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);