]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/x86-pci-fix-pci-irq-routing-table-memory-leak.patch
2af379616775e430ce5fedcd1c1dece1528d4ee8
[thirdparty/kernel/stable-queue.git] / queue-4.19 / x86-pci-fix-pci-irq-routing-table-memory-leak.patch
1 From 7c051093ac4c39d2af975d47e7c8498d42722c06 Mon Sep 17 00:00:00 2001
2 From: Wenwen Wang <wang6495@umn.edu>
3 Date: Wed, 17 Apr 2019 09:18:50 -0500
4 Subject: x86/PCI: Fix PCI IRQ routing table memory leak
5
6 [ Upstream commit ea094d53580f40c2124cef3d072b73b2425e7bfd ]
7
8 In pcibios_irq_init(), the PCI IRQ routing table 'pirq_table' is first
9 found through pirq_find_routing_table(). If the table is not found and
10 CONFIG_PCI_BIOS is defined, the table is then allocated in
11 pcibios_get_irq_routing_table() using kmalloc(). Later, if the I/O APIC is
12 used, this table is actually not used. In that case, the allocated table
13 is not freed, which is a memory leak.
14
15 Free the allocated table if it is not used.
16
17 Signed-off-by: Wenwen Wang <wang6495@umn.edu>
18 [bhelgaas: added Ingo's reviewed-by, since the only change since v1 was to
19 use the irq_routing_table local variable name he suggested]
20 Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
21 Reviewed-by: Ingo Molnar <mingo@kernel.org>
22 Acked-by: Thomas Gleixner <tglx@linutronix.de>
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 ---
25 arch/x86/pci/irq.c | 10 ++++++++--
26 1 file changed, 8 insertions(+), 2 deletions(-)
27
28 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
29 index 52e55108404e..d3a73f9335e1 100644
30 --- a/arch/x86/pci/irq.c
31 +++ b/arch/x86/pci/irq.c
32 @@ -1119,6 +1119,8 @@ static const struct dmi_system_id pciirq_dmi_table[] __initconst = {
33
34 void __init pcibios_irq_init(void)
35 {
36 + struct irq_routing_table *rtable = NULL;
37 +
38 DBG(KERN_DEBUG "PCI: IRQ init\n");
39
40 if (raw_pci_ops == NULL)
41 @@ -1129,8 +1131,10 @@ void __init pcibios_irq_init(void)
42 pirq_table = pirq_find_routing_table();
43
44 #ifdef CONFIG_PCI_BIOS
45 - if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN))
46 + if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN)) {
47 pirq_table = pcibios_get_irq_routing_table();
48 + rtable = pirq_table;
49 + }
50 #endif
51 if (pirq_table) {
52 pirq_peer_trick();
53 @@ -1145,8 +1149,10 @@ void __init pcibios_irq_init(void)
54 * If we're using the I/O APIC, avoid using the PCI IRQ
55 * routing table
56 */
57 - if (io_apic_assign_pci_irqs)
58 + if (io_apic_assign_pci_irqs) {
59 + kfree(rtable);
60 pirq_table = NULL;
61 + }
62 }
63
64 x86_init.pci.fixup_irqs();
65 --
66 2.20.1
67