All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: OMAP2+: Fix CPCAP node reference leaks
@ 2026-11-24 15:10 Yuho Choi
  0 siblings, 0 replies; only message in thread
From: Yuho Choi @ 2026-11-24 15:10 UTC (permalink / raw)
  To: Kevin Hilman, Andreas Kemnade, Aaro Koskinen, Roger Quadros,
	Tony Lindgren
  Cc: Russell King, Pavel Machek, linux-omap, linux-arm-kernel,
	linux-kernel, Yuho Choi

omap4_cpcap_init(), cpcap_late_init() and omap4_twl_init() call
of_find_compatible_node() to check whether the device tree has a
"motorola,cpcap" node. of_find_compatible_node() returns the node with
its reference count raised, but the callers only test the returned
pointer and never drop that reference.

Put the node right after the check.

Fixes: d44fa156dcb2 ("ARM: OMAP2+: Configure voltage controller for cpcap")
Fixes: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
Fixes: 7397daf1029d ("ARM: omap: pmic-cpcap: do not mess around without CPCAP or OMAP4")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (ARM omap2plus_defconfig, W=1). I have no OMAP4
board with a CPCAP PMIC to test it on.

 arch/arm/mach-omap2/omap_twl.c   | 10 ++++++++--
 arch/arm/mach-omap2/pmic-cpcap.c | 11 +++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index d4dab041324d..e103088bb34f 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -213,11 +213,17 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
 int __init omap4_twl_init(void)
 {
 	struct voltagedomain *voltdm;
+	struct device_node *np;
 
-	if (!cpu_is_omap44xx() ||
-	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
+	if (!cpu_is_omap44xx())
 		return -ENODEV;
 
+	np = of_find_compatible_node(NULL, NULL, "motorola,cpcap");
+	if (np) {
+		of_node_put(np);
+		return -ENODEV;
+	}
+
 	voltdm = voltdm_lookup("mpu");
 	omap_voltage_register_pmic(voltdm, &omap4_mpu_pmic);
 
diff --git a/arch/arm/mach-omap2/pmic-cpcap.c b/arch/arm/mach-omap2/pmic-cpcap.c
index 9f9a20274db8..2f487ad41685 100644
--- a/arch/arm/mach-omap2/pmic-cpcap.c
+++ b/arch/arm/mach-omap2/pmic-cpcap.c
@@ -238,9 +238,12 @@ static struct omap_voltdm_pmic omap4_fan_iva = {
 int __init omap4_cpcap_init(void)
 {
 	struct voltagedomain *voltdm;
+	struct device_node *np;
 
-	if (!of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
+	np = of_find_compatible_node(NULL, NULL, "motorola,cpcap");
+	if (!np)
 		return -ENODEV;
+	of_node_put(np);
 
 	voltdm = voltdm_lookup("mpu");
 	omap_voltage_register_pmic(voltdm, &omap443x_max8952_mpu);
@@ -264,8 +267,12 @@ int __init omap4_cpcap_init(void)
 
 static int __init cpcap_late_init(void)
 {
-	if (!of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
+	struct device_node *np;
+
+	np = of_find_compatible_node(NULL, NULL, "motorola,cpcap");
+	if (!np)
 		return 0;
+	of_node_put(np);
 
 	if (soc_is_omap443x() || soc_is_omap446x() || soc_is_omap447x())
 		omap4_vc_set_pmic_signaling(PWRDM_POWER_RET);

base-commit: 8dac6df92a2e66e2098bbc69061964cfe7e8375b
-- 
2.56.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-24 15:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 15:10 [PATCH] ARM: OMAP2+: Fix CPCAP node reference leaks Yuho Choi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.