Commit 9ed244b1 authored by Tyrel Datwyler's avatar Tyrel Datwyler Committed by Greg Kroah-Hartman

PCI: rpadlpar: Fix leaked device_node references in add/remove paths

[ Upstream commit fb26228b ]

The find_dlpar_node() helper returns a device node with its reference
incremented.  Both the add and remove paths use this helper for find the
appropriate node, but fail to release the reference when done.

Annotate the find_dlpar_node() helper with a comment about the incremented
reference count and call of_node_put() on the obtained device_node in the
add and remove paths.  Also, fixup a reference leak in the find_vio_slot()
helper where we fail to call of_node_put() on the vdevice node after we
iterate over its children.
Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 09c9989c
...@@ -51,6 +51,7 @@ static struct device_node *find_vio_slot_node(char *drc_name) ...@@ -51,6 +51,7 @@ static struct device_node *find_vio_slot_node(char *drc_name)
if (rc == 0) if (rc == 0)
break; break;
} }
of_node_put(parent);
return dn; return dn;
} }
...@@ -71,6 +72,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name, ...@@ -71,6 +72,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name,
return np; return np;
} }
/* Returns a device_node with its reference count incremented */
static struct device_node *find_dlpar_node(char *drc_name, int *node_type) static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
{ {
struct device_node *dn; struct device_node *dn;
...@@ -306,6 +308,7 @@ int dlpar_add_slot(char *drc_name) ...@@ -306,6 +308,7 @@ int dlpar_add_slot(char *drc_name)
rc = dlpar_add_phb(drc_name, dn); rc = dlpar_add_phb(drc_name, dn);
break; break;
} }
of_node_put(dn);
printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name); printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name);
exit: exit:
...@@ -439,6 +442,7 @@ int dlpar_remove_slot(char *drc_name) ...@@ -439,6 +442,7 @@ int dlpar_remove_slot(char *drc_name)
rc = dlpar_remove_pci_slot(drc_name, dn); rc = dlpar_remove_pci_slot(drc_name, dn);
break; break;
} }
of_node_put(dn);
vm_unmap_aliases(); vm_unmap_aliases();
printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment