From d08bc5ad7a83f56e0114b1d01bcab853d0da5cfb Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Thu, 26 Mar 2020 14:37:37 +1100 Subject: drivers/net/r8168: Fix leaking memory from mapping BUG=b:152157720,b:152459313 BRANCH=none TEST=none Change-Id: Ie79c3209d0be719ae1394e87efb357b84ce32840 Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/coreboot/+/39855 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/drivers/net/r8168.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c index fcdac90481..99d472ce8e 100644 --- a/src/drivers/net/r8168.c +++ b/src/drivers/net/r8168.c @@ -117,6 +117,7 @@ static enum cb_err fetch_mac_vpd_key(u8 *macstrbuf, const char *vpd_key) if (offset == search_length) { printk(BIOS_ERR, "Error: Could not locate '%s' in VPD\n", vpd_key); + rdev_munmap(&rdev, search_address); return CB_ERR; } printk(BIOS_DEBUG, "Located '%s' in VPD\n", vpd_key); @@ -124,10 +125,12 @@ static enum cb_err fetch_mac_vpd_key(u8 *macstrbuf, const char *vpd_key) offset += strlen(vpd_key) + 1; /* move to next character */ if (offset + MACLEN > search_length) { + rdev_munmap(&rdev, search_address); printk(BIOS_ERR, "Search result too small!\n"); return CB_ERR; } memcpy(macstrbuf, search_address + offset, MACLEN); + rdev_munmap(&rdev, search_address); return CB_SUCCESS; } -- cgit v1.2.3