diff options
| author | Johan Hovold <johan+linaro@kernel.org> | 2025-07-21 17:36:07 +0200 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2025-08-27 14:31:45 -0500 |
| commit | 39f9be6aba3ae4d6fdd4b8554f1184d054d7a713 (patch) | |
| tree | fbe6052656d5bcfee72b5271bc45f765dc2e02fe | |
| parent | ab81f2f79c683c94bac622aafafbe8232e547159 (diff) | |
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: b458ff7e8176 ("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
| -rw-r--r-- | drivers/pci/bus.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index b77fd30bbfd9..f401e296d15d 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -361,11 +361,15 @@ void pci_bus_add_device(struct pci_dev *dev) * before PCI client drivers. */ pdev = of_find_device_by_node(dn); - if (pdev && of_pci_supply_present(dn)) { - if (!device_link_add(&dev->dev, &pdev->dev, - DL_FLAG_AUTOREMOVE_CONSUMER)) - pci_err(dev, "failed to add device link to power control device %s\n", - pdev->name); + if (pdev) { + if (of_pci_supply_present(dn)) { + if (!device_link_add(&dev->dev, &pdev->dev, + DL_FLAG_AUTOREMOVE_CONSUMER)) { + pci_err(dev, "failed to add device link to power control device %s\n", + pdev->name); + } + } + put_device(&pdev->dev); } if (!dn || of_device_is_available(dn)) |