Skip to contentSkip to conversation

pci/hotplug/pnv-php: Remove probable double put

PATCH In review Xu Wang 4 participants 4 messages Sep 7, 2021

Subsystems (2)
lore
Share & tools
lore

Xu Wang

author
#0 lore raw

PATCH 1/1 pci/hotplug/pnv-php: Remove probable double put

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

---
 drivers/pci/hotplug/pnv_php.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pci/hotplug/pnv_php.c +0 -1
index 04565162a449..ed4d1a2c3f22 100644
@@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
 	for_each_child_of_node(parent, dn) {
 		pnv_php_detach_device_nodes(dn);
 
-		of_node_put(dn);
 		of_detach_node(dn);
 	}
 }
Signature · 1 line
2.17.1
#1 lore raw

Make your subject line follow the previous convention.

Figure out if this is a "probable" or a real double put. If it's a real double put, we should fix it. If it's only "probable," that means we don't understand the problem yet.

Quoted 23 lines · Xu Wang

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

---
 drivers/pci/hotplug/pnv_php.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pci/hotplug/pnv_php.c +0 -1
index 04565162a449..ed4d1a2c3f22 100644
@@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
 	for_each_child_of_node(parent, dn) {
 		pnv_php_detach_device_nodes(dn);
 
-		of_node_put(dn);
 		of_detach_node(dn);
 	}
 }
Signature · 1 line
2.17.1
#2 lore raw
In reply to Xu Wang
Quoted 13 lines · Xu Wang

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

---
 drivers/pci/hotplug/pnv_php.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pci/hotplug/pnv_php.c +0 -0
index 04565162a449..ed4d1a2c3f22 100644

drivers/pci/hotplug/pnv_php.c static void pnv_php_detach_device_nodes(struct device_node *parent) · line 161

Quoted 5 lines
drivers/pci/hotplug/pnv_php.c +0 -1
@@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
 	for_each_child_of_node(parent, dn) {
 		pnv_php_detach_device_nodes(dn);
 
-		of_node_put(dn);
 		of_detach_node(dn);

Are you sure this is a double put? This looks to me like its meant to drive tear down of the device by putting a long term reference and not the short term get that is part of the iterator.

-Tyrel

Quoted 3 lines
drivers/pci/hotplug/pnv_php.c +0 -0
 	}
 }
#3 lore raw
Quoted 18 lines · Tyrel Datwyler
Quoted 16 lines · Xu Wang

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

---
 drivers/pci/hotplug/pnv_php.c | 1 -
 1 file changed, 1 deletion(-)
drivers/pci/hotplug/pnv_php.c +0 -0
index 04565162a449..ed4d1a2c3f22 100644
@@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
      for_each_child_of_node(parent, dn) {
              pnv_php_detach_device_nodes(dn);
 
Quoted 6 lines

drivers/pci/hotplug/pnv_php.c static void pnv_php_detach_device_nodes(struct device_node *parent) · line 161

Quoted 2 lines
drivers/pci/hotplug/pnv_php.c +0 -1
-             of_node_put(dn);
              of_detach_node(dn);

Are you sure this is a double put? This looks to me like its meant to drive tear down of the device by putting a long term reference and not the short term get that is part of the iterator.

Yeah, the put is there is to drop the initial ref so the node can be released. It might be worth adding a comment.