]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.11.9/arm64-pci-fix-struct-acpi_pci_root_ops-allocation-failure-path.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.11.9 / arm64-pci-fix-struct-acpi_pci_root_ops-allocation-failure-path.patch
CommitLineData
0a9fa856
GKH
1From 717902cc93118119a6fce7765da6cf2786987418 Mon Sep 17 00:00:00 2001
2From: Timmy Li <lixiaoping3@huawei.com>
3Date: Mon, 22 May 2017 16:48:28 +0100
4Subject: ARM64: PCI: Fix struct acpi_pci_root_ops allocation failure path
5
6From: Timmy Li <lixiaoping3@huawei.com>
7
8commit 717902cc93118119a6fce7765da6cf2786987418 upstream.
9
10Commit 093d24a20442 ("arm64: PCI: Manage controller-specific data on
11per-controller basis") added code to allocate ACPI PCI root_ops
12dynamically on a per host bridge basis but failed to update the
13corresponding memory allocation failure path in pci_acpi_scan_root()
14leading to a potential memory leakage.
15
16Fix it by adding the required kfree call.
17
18Fixes: 093d24a20442 ("arm64: PCI: Manage controller-specific data on per-controller basis")
19Reviewed-by: Tomasz Nowicki <tn@semihalf.com>
20Signed-off-by: Timmy Li <lixiaoping3@huawei.com>
21[lorenzo.pieralisi@arm.com: refactored code, rewrote commit log]
22Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
23CC: Will Deacon <will.deacon@arm.com>
24CC: Bjorn Helgaas <bhelgaas@google.com>
25Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
26Signed-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) {