Skip to content

Commit 39f9be6

Browse files
jhovoldbjorn-helgaas
authored andcommitted
PCI/pwrctrl: Fix device leak at registration
Make sure to drop the reference to the pwrctrl device taken by of_find_device_by_node() when registering a PCI device. Fixes: b458ff7 ("PCI/pwrctl: Ensure that pwrctl drivers are probed before PCI client drivers") Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Cc: stable@vger.kernel.org # v6.13 Link: https://patch.msgid.link/20250721153609.8611-2-johan+linaro@kernel.org
1 parent ab81f2f commit 39f9be6

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/pci/bus.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,15 @@ void pci_bus_add_device(struct pci_dev *dev)
361361
* before PCI client drivers.
362362
*/
363363
pdev = of_find_device_by_node(dn);
364-
if (pdev && of_pci_supply_present(dn)) {
365-
if (!device_link_add(&dev->dev, &pdev->dev,
366-
DL_FLAG_AUTOREMOVE_CONSUMER))
367-
pci_err(dev, "failed to add device link to power control device %s\n",
368-
pdev->name);
364+
if (pdev) {
365+
if (of_pci_supply_present(dn)) {
366+
if (!device_link_add(&dev->dev, &pdev->dev,
367+
DL_FLAG_AUTOREMOVE_CONSUMER)) {
368+
pci_err(dev, "failed to add device link to power control device %s\n",
369+
pdev->name);
370+
}
371+
}
372+
put_device(&pdev->dev);
369373
}
370374

371375
if (!dn || of_device_is_available(dn))

0 commit comments

Comments
 (0)