]>
Commit | Line | Data |
---|---|---|
0a9fa856 GKH |
1 | From 717902cc93118119a6fce7765da6cf2786987418 Mon Sep 17 00:00:00 2001 |
2 | From: Timmy Li <lixiaoping3@huawei.com> | |
3 | Date: Mon, 22 May 2017 16:48:28 +0100 | |
4 | Subject: ARM64: PCI: Fix struct acpi_pci_root_ops allocation failure path | |
5 | ||
6 | From: Timmy Li <lixiaoping3@huawei.com> | |
7 | ||
8 | commit 717902cc93118119a6fce7765da6cf2786987418 upstream. | |
9 | ||
10 | Commit 093d24a20442 ("arm64: PCI: Manage controller-specific data on | |
11 | per-controller basis") added code to allocate ACPI PCI root_ops | |
12 | dynamically on a per host bridge basis but failed to update the | |
13 | corresponding memory allocation failure path in pci_acpi_scan_root() | |
14 | leading to a potential memory leakage. | |
15 | ||
16 | Fix it by adding the required kfree call. | |
17 | ||
18 | Fixes: 093d24a20442 ("arm64: PCI: Manage controller-specific data on per-controller basis") | |
19 | Reviewed-by: Tomasz Nowicki <tn@semihalf.com> | |
20 | Signed-off-by: Timmy Li <lixiaoping3@huawei.com> | |
21 | [lorenzo.pieralisi@arm.com: refactored code, rewrote commit log] | |
22 | Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | |
23 | CC: Will Deacon <will.deacon@arm.com> | |
24 | CC: Bjorn Helgaas <bhelgaas@google.com> | |
25 | Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> | |
26 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
27 | ||
28 | --- | |
29 | arch/arm64/kernel/pci.c | 4 +++- | |
30 | 1 file changed, 3 insertions(+), 1 deletion(-) | |
31 | ||
32 | --- a/arch/arm64/kernel/pci.c | |
33 | +++ b/arch/arm64/kernel/pci.c | |
34 | @@ -191,8 +191,10 @@ struct pci_bus *pci_acpi_scan_root(struc | |
35 | return NULL; | |
36 | ||
37 | root_ops = kzalloc_node(sizeof(*root_ops), GFP_KERNEL, node); | |
38 | - if (!root_ops) | |
39 | + if (!root_ops) { | |
40 | + kfree(ri); | |
41 | return NULL; | |
42 | + } | |
43 | ||
44 | ri->cfg = pci_acpi_setup_ecam_mapping(root); | |
45 | if (!ri->cfg) { |