Skip to content

Commit 8b19d72

Browse files
Tyrel Datwylergregkh
authored andcommitted
PCI: rpadlpar: Fix leaked device_node references in add/remove paths
[ Upstream commit fb26228 ] 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: Tyrel Datwyler <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent db2d470 commit 8b19d72

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/pci/hotplug/rpadlpar_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static struct device_node *find_vio_slot_node(char *drc_name)
5555
if ((rc == 0) && (!strcmp(drc_name, name)))
5656
break;
5757
}
58+
of_node_put(parent);
5859

5960
return dn;
6061
}
@@ -78,6 +79,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name,
7879
return np;
7980
}
8081

82+
/* Returns a device_node with its reference count incremented */
8183
static struct device_node *find_dlpar_node(char *drc_name, int *node_type)
8284
{
8385
struct device_node *dn;
@@ -313,6 +315,7 @@ int dlpar_add_slot(char *drc_name)
313315
rc = dlpar_add_phb(drc_name, dn);
314316
break;
315317
}
318+
of_node_put(dn);
316319

317320
printk(KERN_INFO "%s: slot %s added\n", DLPAR_MODULE_NAME, drc_name);
318321
exit:
@@ -446,6 +449,7 @@ int dlpar_remove_slot(char *drc_name)
446449
rc = dlpar_remove_pci_slot(drc_name, dn);
447450
break;
448451
}
452+
of_node_put(dn);
449453
vm_unmap_aliases();
450454

451455
printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name);

0 commit comments

Comments
 (0)