History

x86/PCI: Fix PCI IRQ routing table memory leak

In pcibios_irq_init(), the PCI IRQ routing table 'pirq_table' is first found through pirq_find_routing_table(). If the table is not found and CONFIG_PCI_BIOS is defined, the table is then allocated in pcibios_get_irq_routing_table() using kmalloc(). Later, if the I/O APIC is used, this table is actually not used. In that case, the allocated table is not freed, which is a memory leak. Free the allocated table if it is not used.

Wenwen Wang committed 7 years ago

Commit ea094d51 parent 804ee5b1 file · +8 −2Browse files

Unified · Split

arch/x86/pci/irq.c+8−2
@@ -1119,6 +1119,8 @@ static const struct dmi_system_id pciirq_dmi_table[] __initconst = { · 1118 unmodified lines
1119 1119
1120void __init pcibios_irq_init(void)1120void __init pcibios_irq_init(void)
1121{1121{
1122 struct irq_routing_table *rtable = NULL;
1123
1122 DBG(KERN_DEBUG "PCI: IRQ init\n");1124 DBG(KERN_DEBUG "PCI: IRQ init\n");
1123 1125
1124 if (raw_pci_ops == NULL)1126 if (raw_pci_ops == NULL)
@@ -1129,8 +1131,10 @@ void __init pcibios_irq_init(void) · 4 unmodified lines
1129 pirq_table = pirq_find_routing_table();1131 pirq_table = pirq_find_routing_table();
1130 1132
1131#ifdef CONFIG_PCI_BIOS1133#ifdef CONFIG_PCI_BIOS
1132 if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN))1134 if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN)) {
1133 pirq_table = pcibios_get_irq_routing_table();1135 pirq_table = pcibios_get_irq_routing_table();
1136 rtable = pirq_table;
1137 }
1134#endif1138#endif
1135 if (pirq_table) {1139 if (pirq_table) {
1136 pirq_peer_trick();1140 pirq_peer_trick();
@@ -1145,8 +1149,10 @@ void __init pcibios_irq_init(void) · 8 unmodified lines
1145 * If we're using the I/O APIC, avoid using the PCI IRQ1149 * If we're using the I/O APIC, avoid using the PCI IRQ
1146 * routing table1150 * routing table
1147 */1151 */
1148 if (io_apic_assign_pci_irqs)1152 if (io_apic_assign_pci_irqs) {
1153 kfree(rtable);
1149 pirq_table = NULL;1154 pirq_table = NULL;
1155 }
1150 }1156 }
1151 1157
1152 x86_init.pci.fixup_irqs();1158 x86_init.pci.fixup_irqs();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t