Skip to contentSkip to conversation

pci: host: pci-layerscape: add missing of_node_put after calling of_parse_phandle

PATCH In review Peter Chen 2 participants 3 messages Aug 12, 2016 – Aug 25, 2016 PCI

lore
Share & tools
lore

Peter Chen

author
#0 lore raw

PATCH 1/1 pci: host: pci-layerscape: add missing of_node_put after calling of_parse_phandle

of_node_put needs to be called when the device node which is got from of_parse_phandle has finished using.

Cc Minghuan Lian <[email protected]>
Cc Mingkai Hu <[email protected]>
Cc Roy Zang <[email protected]>
---
 drivers/pci/host/pci-layerscape.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/host/pci-layerscape.c +2 -0
index 114ba81..573b996 100644
@@ -173,6 +173,8 @@ static int ls_pcie_msi_host_init(struct pcie_port *pp,
 		return -EINVAL;
 	}
 
+	of_node_put(msi_node);
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#1 lore raw

Hi Peter,

Quoted 16 lines · Peter Chen

of_node_put needs to be called when the device node which is got from of_parse_phandle has finished using.

Cc Minghuan Lian <[email protected]>
Cc Mingkai Hu <[email protected]>
Cc Roy Zang <[email protected]>
---
 drivers/pci/host/pci-layerscape.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/host/pci-layerscape.c +0 -0
index 114ba81..573b996 100644

drivers/pci/host/pci-layerscape.c static int ls_pcie_msi_host_init(struct pcie_port *pp, · line 177

Quoted 5 lines
drivers/pci/host/pci-layerscape.c +2 -0
@@ -173,6 +173,8 @@ static int ls_pcie_msi_host_init(struct pcie_port *pp,
 		return -EINVAL;
 	}
 
+	of_node_put(msi_node);
+

Can you please look for and fix similar errors in other drivers in drivers/pci/host/*?

For example:

advk_pcie_probe() and iproc_pcie_msi_enable() call of_parse_phandle() but don't call of_node_put() in failure paths.

dra7xx_pcie_init_irq_domain(), nwl_pcie_init_irq_domain(), and xilinx_pcie_init_irq_domain() call of_get_next_child() but don't call of_node_put() in failure paths.

ks_pcie_get_irq_controller_info() calls of_find_node_by_name().

I think there may be others, e.g., the pci_host_bridge_msi_domain() path calls of_parse_phandle(), but I'm not sure of_node_put() is called on failure paths.

When we find bugs like this, it's nice to fix one occurrence, but it's really great if we can squash similar bugs nearby so the bug isn't copied into new drivers.

Quoted 10 lines
drivers/pci/host/pci-layerscape.c +0 -0
 	return 0;
 }
 
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#2 lore raw

=20

Quoted 13 lines · Peter Chen
Quoted 11 lines

of_node_put needs to be called when the device node which is got from of_parse_phandle has finished using.

Cc Minghuan Lian <[email protected]>
Cc Mingkai Hu <[email protected]>
Cc Roy Zang <[email protected]>
---
 drivers/pci/host/pci-layerscape.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 6 lines

drivers/pci/host/pci-layerscape.c static int ls_pcie_msi_host_init(struct pcie_port *p=

Quoted 6 lines
drivers/pci/host/pci-layerscape.c +0 -0
index 114ba81..573b996 100644
@@ -173,6 +173,8 @@ static int ls_pcie_msi_host_init(struct pcie_port *p=

p,

Quoted 7 lines

drivers/pci/host/pci-layerscape.c static int ls_pcie_msi_host_init(struct pcie_port *pp, · line 177

Quoted 5 lines
drivers/pci/host/pci-layerscape.c +2 -0
 		return -EINVAL;
 	}
 
+	of_node_put(msi_node);
+

Can you please look for and fix similar errors in other drivers in drivers=

/pci/host/*?

Quoted 12 lines

For example:

advk_pcie_probe() and iproc_pcie_msi_enable() call of_parse_phandle() but don't call of_node_put() in failure paths.

dra7xx_pcie_init_irq_domain(), nwl_pcie_init_irq_domain(), and xilinx_pcie_init_irq_domain() call of_get_next_child() but don't call of_node_put() in failure paths.

ks_pcie_get_irq_controller_info() calls of_find_node_by_name().

Would you agree that I fix the issues for drivers that call of_parse_phandl= e or of_get_next_child
or of_find_node_by_name? I can grep the symbols, and check if of_node_put i= s called properly.
I will group all fixed within one patch set.

Quoted 1 line

I think there may be others, e.g., the pci_host_bridge_msi_domain() path c=

alls

Quoted 1 line

of_parse_phandle(), but I'm not sure of_node_put() is called on failure pa=

ths.

Quoted 1 line

I find pci_host_bridge_msi_domain does not call of_parse_phandle directly, = only of_msi_get_domain calls of_parse_phandle, and
of_node_put is called properly.

Peter

Quoted 1 line

When we find bugs like this, it's nice to fix one occurrence, but it's rea=

lly great if we

Quoted 12 lines

can squash similar bugs nearby so the bug isn't copied into new drivers.

Quoted 10 lines
drivers/pci/host/pci-layerscape.c +0 -1
 	return 0;
 }
 
--

1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html