re: [PATCH] PCI: add proper MCFG table parsing to ACPI core.

From: Konrad Rzeszutek
Date: Thu Jun 15 2006 - 12:07:17 EST


Hey Greg,

This a bit late (yours patch was posted about a year ago), but
a co-worker of spotted part of the code that looks like a memory
leak. Looking at the code it seems that pci_mmcfg_config should
be free-ed if MMCONFIG is above 4GB.

> +/* The physical address of the MMCONFIG aperture. Set from ACPI
> tables. */
> + config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
> + pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
> + memcpy(pci_mmcfg_config, &mcfg->config, config_size);
> + for (i = 0; i < pci_mmcfg_config_num; ++i) {
> + if (mcfg->config[i].base_reserved) {
> + printk(KERN_ERR PREFIX
> + "MMCONFIG not in low 4GB of memory\n");
> + return -ENODEV;

Here is a proposed patch. What are your thoughts?

diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 40e5aba..fbe9308 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -202,6 +202,8 @@ int __init acpi_parse_mcfg(unsigned long
if (mcfg->config[i].base_reserved) {
printk(KERN_ERR PREFIX
"MMCONFIG not in low 4GB of memory\n");
+ kfree(pci_mmcfg_config);
+ pci_mmcfg_config_num = 0;
return -ENODEV;
}
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/