diff mbox series

[v2,2/2] powerpc: cell: iommu: Hold reference returned by of_find_node_by_name()

Message ID 20220701144949.252364-2-windhl@126.com (mailing list archive)
State Accepted
Headers show
Series [v2,1/2] powerpc: cell: cbe_regs: Fix refcount bugs | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 10 jobs.
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 10 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 23 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 7 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.

Commit Message

Liang He July 1, 2022, 2:49 p.m. UTC
In cell_iommu_init_disabled(), we should hold the reference returned
by of_find_node_by_name() and use it to call of_node_put() for reference
balance.

Signed-off-by: Liang He <windhl@126.com>
---
 changelog:

 v2: (1) split v1's two files in to two commits
     (2) using 'check-then-put' coding style
 v1: hold the reference returned by of_find_xxx OF APIs

 v1-link: https://lore.kernel.org/all/20220621075333.4081413-1-windhl@126.com/

 arch/powerpc/platforms/cell/iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 0ca3efeef293..8c7133039566 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -720,8 +720,10 @@  static int __init cell_iommu_init_disabled(void)
 	cell_disable_iommus();
 
 	/* If we have no Axon, we set up the spider DMA magic offset */
-	if (of_find_node_by_name(NULL, "axon") == NULL)
+	np = of_find_node_by_name(NULL, "axon");
+	if (!np)
 		cell_dma_nommu_offset = SPIDER_DMA_OFFSET;
+	of_node_put(np);
 
 	/* Now we need to check to see where the memory is mapped
 	 * in PCI space. We assume that all busses use the same dma