[PATCH] sparc: Fix leaked platform_device references in archdata propagation
From: Ma Ke
Date: Sun Oct 11 2026 - 06:37:13 EST
of_propagate_archdata() walks the children of a bus node and looks each
one up with of_find_device_by_node(), documented in
drivers/of/platform.c:
* Takes a reference to the embedded struct device which needs to be
* dropped after use.
The reference is never dropped, and because the function recurses, every
child node of every ebus leaks the reference to its platform_device.
Found by code review.
Fixes: 5059625ed886 ("sparc: Add OF archdata propagation helper.")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ma Ke <make_ruc2021@xxxxxxx>
---
arch/sparc/kernel/of_device_common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c
index 7f2f9972b59b..0aae21c4b62c 100644
--- a/arch/sparc/kernel/of_device_common.c
+++ b/arch/sparc/kernel/of_device_common.c
@@ -70,6 +70,8 @@ void of_propagate_archdata(struct platform_device *bus)
if (dp->child)
of_propagate_archdata(op);
+
+ platform_device_put(op);
}
}
--
2.43.0