diff options
| author | Bjorn Helgaas <bhelgaas@google.com> | 2025-10-03 12:13:11 -0500 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2025-10-03 12:13:11 -0500 |
| commit | b365c0a76946b3f18e835c1ee85a280753f9a9b0 (patch) | |
| tree | a4eedf6e2ad7139312ef965f2571113816968b52 /drivers/pci/probe.c | |
| parent | 4c5cd8d64172de3730056366dc61392a3f2f003a (diff) | |
| parent | dc32e9346b26ba33e84ec3034a1e53a9733700f9 (diff) | |
Merge branch 'pci/pwrctrl'
- Fix a double cleanup of regulators if devm_add_action_or_reset() fails
(Geert Uytterhoeven)
* pci/pwrctrl:
PCI/pwrctrl: Fix device leak at device stop
PCI/pwrctrl: Fix device and OF node leak at bus scan
PCI/pwrctrl: Fix device leak at registration
PCI/pwrctrl: Fix double cleanup on devm_add_action_or_reset() failure
Diffstat (limited to 'drivers/pci/probe.c')
| -rw-r--r-- | drivers/pci/probe.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 591aee60e3d0..231f0dff8b01 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2517,9 +2517,15 @@ static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, in struct device_node *np; np = of_pci_find_child_device(dev_of_node(&bus->dev), devfn); - if (!np || of_find_device_by_node(np)) + if (!np) return NULL; + pdev = of_find_device_by_node(np); + if (pdev) { + put_device(&pdev->dev); + goto err_put_of_node; + } + /* * First check whether the pwrctrl device really needs to be created or * not. This is decided based on at least one of the power supplies @@ -2527,17 +2533,24 @@ static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, in */ if (!of_pci_supply_present(np)) { pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name); - return NULL; + goto err_put_of_node; } /* Now create the pwrctrl device */ pdev = of_platform_device_create(np, NULL, &host->dev); if (!pdev) { pr_err("PCI/pwrctrl: Failed to create pwrctrl device for node: %s\n", np->name); - return NULL; + goto err_put_of_node; } + of_node_put(np); + return pdev; + +err_put_of_node: + of_node_put(np); + + return NULL; } #else static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn) |
