From 40672becaa44a0d71f6a312335cc4c028d60199b Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Tue, 8 Mar 2016 11:01:17 -0600 Subject: drivers/intel/fsp2_0: don't leak resources rdev_mmap() was not followed by rdev_munmap(), thus leaking resources. Fix the leak. Change-Id: Ibdd30d6b64616038013b4bb748f2ad4a98db5472 Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/13958 Reviewed-by: Furquan Shaikh Tested-by: build bot (Jenkins) Reviewed-by: Andrey Petrov --- src/drivers/intel/fsp2_0/util.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/drivers/intel/fsp2_0/util.c b/src/drivers/intel/fsp2_0/util.c index 4fd4f689a3..da8aa9c271 100644 --- a/src/drivers/intel/fsp2_0/util.c +++ b/src/drivers/intel/fsp2_0/util.c @@ -95,11 +95,20 @@ enum cb_err fsp_load_binary(struct fsp_header *hdr, /* Map just enough of the file to be able to parse the header. */ membase = rdev_mmap(&file_data, FSP_HDR_OFFSET, FSP_HDR_LEN); + + if (membase == NULL) { + printk(BIOS_ERR, "Could not mmap() '%s' FSP header.\n", name); + return CB_ERR; + } + if (fsp_identify(hdr, membase) != CB_SUCCESS) { + rdev_munmap(&file_data, membase); printk(BIOS_ERR, "%s did not have a valid FSP header\n", name); return CB_ERR; } + rdev_munmap(&file_data, membase); + fsp_print_header_info(hdr); /* Check if size specified in the header matches the cbfs file size */ -- cgit v1.2.3