[PATCH] powerpc/powermac/low_i2c: Fix refcount leak bug in kw_i2c_probe()

Liang He windhl at 126.com
Sat Jul 16 17:07:58 AEST 2022


We should call of_node_put() for the reference 'parent' returned by
of_get_parent() which has increased the refcount.

Fixes: 730745a5c450 ("[PATCH] 1/5 powerpc: Rework PowerMac i2c part 1")
Signed-off-by: Liang He <windhl at 126.com>
---
 arch/powerpc/platforms/powermac/low_i2c.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index c1c430c66dc9..40f3aa432fba 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -627,6 +627,7 @@ static void __init kw_i2c_probe(void)
 			if (parent == NULL)
 				continue;
 			chans = parent->name[0] == 'u' ? 2 : 1;
+			of_node_put(parent);
 			for (i = 0; i < chans; i++)
 				kw_i2c_add(host, np, np, i);
 		} else {
-- 
2.25.1



More information about the Linuxppc-dev mailing list