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 <bernacki@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74779
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Reviewed-by: Tim Van Patten <timvp@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Himanshu Sahdev <himanshu.sahdev@intel.com>
This commit is contained in:
Grzegorz Bernacki 2023-04-25 15:37:57 +00:00 committed by Martin L Roth
parent e6b4597fef
commit 4aa31ac3f9
1 changed files with 13 additions and 3 deletions

View File

@ -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);
}