From 4aa31ac3f974df74976ee4f970a90ea14ca617f6 Mon Sep 17 00:00:00 2001 From: Grzegorz Bernacki Date: Tue, 25 Apr 2023 15:37:57 +0000 Subject: soc/amd/common/block/graphics: Add missing pci_rom_free() pci_rom_probe() can allocate memory when mapping a CBFS file, so pci_rom_free() should be called before leaving the function. BUG=b:278264488 TEST=Build and run with additional debug prints added to confirm that data are correctly unmapped Change-Id: Ie6fbbfd36f0974551befef4d08423a8148e151e7 Signed-off-by: Grzegorz Bernacki Reviewed-on: https://review.coreboot.org/c/coreboot/+/74779 Reviewed-by: Karthik Ramasubramanian Reviewed-by: Tim Van Patten Tested-by: build bot (Jenkins) Reviewed-by: Himanshu Sahdev --- src/soc/amd/common/block/graphics/graphics.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/soc/amd/common/block/graphics/graphics.c b/src/soc/amd/common/block/graphics/graphics.c index d8f3e1fd86..93f71f9ce9 100644 --- a/src/soc/amd/common/block/graphics/graphics.c +++ b/src/soc/amd/common/block/graphics/graphics.c @@ -157,11 +157,21 @@ static void graphics_set_resources(struct device *const dev) return; } rom = pci_rom_probe(dev); - if (rom == NULL) + if (rom == NULL) { + printk(BIOS_ERR, "%s: Unable to find ROM for %s\n", + __func__, dev_path(dev)); + timestamp_add_now(TS_OPROM_COPY_END); return; + } + ram = pci_rom_load(dev, rom); - if (ram == NULL) - return; + if (ram == NULL) { + printk(BIOS_ERR, "%s: Unable to load ROM for %s\n", + __func__, dev_path(dev)); + } + + pci_rom_free(rom); + timestamp_add_now(TS_OPROM_COPY_END); } -- cgit v1.2.3