Skip to contentSkip to conversation

PCI: free of node in pci_scan_device's error path

PATCH In review Dmitry Baryshkov 3 participants 3 messages Jan 24, 2021 – Mar 23, 2021 PCI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: free of node in pci_scan_device's error path

In the pci_scan_device() if pci_setup_device() fails for any reason, the code will not release device's of_node by calling pci_release_of_node(). Fix that by calling the release function.

Fixes 98d9f30c820d ("pci/of: Match PCI devices to OF nodes dynamically")

---

Changes since v1:
- Changed the order of Fixes and S-o-B tags.

---
 drivers/pci/probe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/probe.c +1 -0
index 953f15abc850..be51670572fa 100644
@@ -2353,6 +2353,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
 	pci_set_of_node(dev);
 
 	if (pci_setup_device(dev)) {
+		pci_release_of_node(dev);
 		pci_bus_put(dev->bus);
 		kfree(dev);
 		return NULL;
Signature · 1 line
2.29.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Dmitry Baryshkov

In the pci_scan_device() if pci_setup_device() fails for any reason, the code will not release device's of_node by calling pci_release_of_node(). Fix that by calling the release function.

Fixes 98d9f30c820d ("pci/of: Match PCI devices to OF nodes dynamically")
Quoted 9 lines

---

Changes since v1:
- Changed the order of Fixes and S-o-B tags.

---
 drivers/pci/probe.c | 1 +
 1 file changed, 1 insertion(+)

Thanks,

#2 lore raw
In reply to Dmitry Baryshkov
Quoted 6 lines · Dmitry Baryshkov

In the pci_scan_device() if pci_setup_device() fails for any reason, the code will not release device's of_node by calling pci_release_of_node(). Fix that by calling the release function.

Fixes 98d9f30c820d ("pci/of: Match PCI devices to OF nodes dynamically")

Applied with Leon's reviewed-by to pci/enumeration for v5.13, thanks!

Quoted 25 lines

---

Changes since v1:
- Changed the order of Fixes and S-o-B tags.

---
 drivers/pci/probe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/probe.c +1 -0
index 953f15abc850..be51670572fa 100644
@@ -2353,6 +2353,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
 	pci_set_of_node(dev);
 
 	if (pci_setup_device(dev)) {
+		pci_release_of_node(dev);
 		pci_bus_put(dev->bus);
 		kfree(dev);
 		return NULL;
Signature · 1 line
2.29.2