diff mbox series

powerpc: 85xx: Fix refcount bugs in ge_imp3a_pci_assign_primary()

Message ID 20220701140119.245435-1-windhl@126.com (mailing list archive)
State Accepted
Headers show
Series powerpc: 85xx: Fix refcount bugs in ge_imp3a_pci_assign_primary() | expand

Checks

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

Commit Message

Liang He July 1, 2022, 2:01 p.m. UTC
for_each_node_by_type() will automatically increase and decrease
the refcount during the iteration. However, there is a reference
escaped into global 'fsl_pci_primary' and we need to handle it.

Signed-off-by: Liang He <windhl@126.com>
---
 arch/powerpc/platforms/85xx/ge_imp3a.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Michael Ellerman Sept. 9, 2022, 12:07 p.m. UTC | #1
On Fri, 1 Jul 2022 22:01:19 +0800, Liang He wrote:
> for_each_node_by_type() will automatically increase and decrease
> the refcount during the iteration. However, there is a reference
> escaped into global 'fsl_pci_primary' and we need to handle it.
> 
> 

Applied to powerpc/next.

[1/1] powerpc: 85xx: Fix refcount bugs in ge_imp3a_pci_assign_primary()
      https://git.kernel.org/powerpc/c/a8b89c10e6052027061a447ff7436642310c8f20

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/85xx/ge_imp3a.c b/arch/powerpc/platforms/85xx/ge_imp3a.c
index 8e827376d97b..e3e8f18825a1 100644
--- a/arch/powerpc/platforms/85xx/ge_imp3a.c
+++ b/arch/powerpc/platforms/85xx/ge_imp3a.c
@@ -89,8 +89,10 @@  static void __init ge_imp3a_pci_assign_primary(void)
 		    of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
 		    of_device_is_compatible(np, "fsl,p2020-pcie")) {
 			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x9000)
-				fsl_pci_primary = np;
+			if ((rsrc.start & 0xfffff) == 0x9000) {
+				of_node_put(fsl_pci_primary);
+				fsl_pci_primary = of_node_get(np);
+			}
 		}
 	}
 #endif