summaryrefslogtreecommitdiff
path: root/util/cbfstool
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-07-02 17:50:59 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-07-10 18:21:00 +0000
commit2e31ea05bb2c88913310d20a9baaa83e8934da52 (patch)
treea4508d45c1b72ca2faf709467b91976df70bc2d4 /util/cbfstool
parent509f46953ece919b1610b685599e146461ae4163 (diff)
util/cbfstool: Close file on error
Prevents a resource leak. Change-Id: I032227228c8e37e989960ad6292ded39b81835a9 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 1383919 Reviewed-on: https://review.coreboot.org/c/coreboot/+/33992 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/cbfstool')
-rw-r--r--util/cbfstool/partitioned_file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/cbfstool/partitioned_file.c b/util/cbfstool/partitioned_file.c
index 9abd32aab6..a2d9ddfee2 100644
--- a/util/cbfstool/partitioned_file.c
+++ b/util/cbfstool/partitioned_file.c
@@ -197,8 +197,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)
+ if (!fmap_fmap_entry) {
+ partitioned_file_close(file);
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",