[coreboot-gerrit] New patch to review for coreboot: drivers/intel/fsp2_0: don't leak resources

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Tue Mar 8 18:26:59 CET 2016


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13958

-gerrit

commit ce91643627525bb4fd569eb98df55cd71271c8a9
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Tue Mar 8 11:01:17 2016 -0600

    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 <adurbin at chromium.org>
---
 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 4fd4f68..da8aa9c 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 */



More information about the coreboot-gerrit mailing list