[PATCH 1/2] powerpc: Fix a memory leak in error handling paths
From: Christophe JAILLET
Date: Fri Apr 23 2021 - 10:40:43 EST
If we exit the for_each_of_cpu_node loop early, the reference on the
current node must be decremented, otherwise there is a leak.
Fixes: a94fe366340a ("powerpc: use for_each_of_cpu_node iterator")
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
Strangely, the commit above added the needed of_node_put in one place but
missed 2 other places!
This is strange, so maybe I misunderstand something. Review carefully
---
arch/powerpc/platforms/powermac/feature.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 5c77b9a24c0e..e612222f7d2e 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1060,6 +1060,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
continue;
if (param == *num) {
reset_io = *rst;
+ of_node_put(np);
break;
}
}
@@ -1506,6 +1507,7 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
continue;
if (param == *num) {
reset_io = *rst;
+ of_node_put(np);
break;
}
}
--
2.27.0