]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.4/pci-rpadlpar-fix-leaked-device_node-references-in-ad.patch
Merge branch 'master' of gitolite.kernel.org:/pub/scm/linux/kernel/git/stable/stable...
[thirdparty/kernel/stable-queue.git] / queue-4.4 / pci-rpadlpar-fix-leaked-device_node-references-in-ad.patch
CommitLineData
cd033818
SL
1From a1d50cc0cf82c76e9be9d1aad951d743bcd9f367 Mon Sep 17 00:00:00 2001
2From: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
3Date: Fri, 22 Mar 2019 13:27:21 -0500
4Subject: PCI: rpadlpar: Fix leaked device_node references in add/remove paths
5
6[ Upstream commit fb26228bfc4ce3951544848555c0278e2832e618 ]
7
8The find_dlpar_node() helper returns a device node with its reference
9incremented. Both the add and remove paths use this helper for find the
10appropriate node, but fail to release the reference when done.
11
12Annotate the find_dlpar_node() helper with a comment about the incremented
13reference count and call of_node_put() on the obtained device_node in the
14add and remove paths. Also, fixup a reference leak in the find_vio_slot()
15helper where we fail to call of_node_put() on the vdevice node after we
16iterate over its children.
17
18Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
19Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
20Signed-off-by: Sasha Levin <sashal@kernel.org>
21---
22 drivers/pci/hotplug/rpadlpar_core.c | 4 ++++
23 1 file changed, 4 insertions(+)
24
25diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
26index f2fcbe944d94..aae295708ea7 100644
27--- a/drivers/pci/hotplug/rpadlpar_core.c
28+++ b/drivers/pci/hotplug/rpadlpar_core.c
29@@ -55,6 +55,7 @@ static struct device_node *find_vio_slot_node(char *drc_name)
30 if ((rc == 0) && (!strcmp(drc_name, name)))
31 break;
32 }
33+ of_node_put(parent);
34
35 return dn;
36 }
37@@ -78,6 +79,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name,
38 return np;
39 }
40
41+/* Returns a device_node with its reference count incremented */
42 static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
43 {
44 struct device_node *dn;
45@@ -314,6 +316,7 @@ int dlpar_add_slot(char *drc_name)
46 rc = dlpar_add_phb(drc_name, dn);
47 break;
48 }
49+ of_node_put(dn);
50
51 printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name);
52 exit:
53@@ -447,6 +450,7 @@ int dlpar_remove_slot(char *drc_name)
54 rc = dlpar_remove_pci_slot(drc_name, dn);
55 break;
56 }
57+ of_node_put(dn);
58 vm_unmap_aliases();
59
60 printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name);
61--
622.20.1
63