Thread (5 messages) flat view 5 messages, 3 authors, 2022-09-09

Re: [PATCH] powerpc: kernel: pci_dn: Add missing of_node_put() for of_get_xx API

From: Tyrel Datwyler <tyreld@linux.ibm.com>
Date: 2022-07-01 22:19:52

On 7/1/22 12:47, Tyrel Datwyler wrote:
On 7/1/22 06:17, Liang He wrote:
quoted
In pci_add_device_node_info(), we should use of_node_put() for the
reference 'parent' returned by of_get_parent() to keep refcount
balance.

Fixes: cca87d303c85 ("powerpc/pci: Refactor pci_dn")
Co-authored-by: Miaoqian Lin [off-list ref]
Signed-off-by: Liang He <redacted>
---
 arch/powerpc/kernel/pci_dn.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 938ab8838ab5..aa221958007e 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -330,6 +330,7 @@ struct pci_dn *pci_add_device_node_info(struct pci_controller *hose,
 	INIT_LIST_HEAD(&pdn->list);
 	parent = of_get_parent(dn);
 	pdn->parent = parent ? PCI_DN(parent) : NULL;
NACK

pdn->parent is now a long term reference so we should not do a put on parent
until we pdn->parent is no longer valid.
I withdraw my NACK. On closer inspection pdn->parent is a reference to the
parent struct pci_dn and not a reference to a parent struct device_node.

Reviewed-by: Tyrel Datwyler <tyreld@linux.ibm.com>
-Tyrel
quoted
+	of_node_put(parent);
 	if (pdn->parent)
 		list_add_tail(&pdn->list, &pdn->parent->child_list);
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help