Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Yuho Choi <oss.patchbox@gmail.com>
To: Kevin Hilman <khilman@baylibre.com>,
	Andreas Kemnade <andreas@kemnade.info>,
	Aaro Koskinen <aaro.koskinen@iki.fi>,
	Roger Quadros <rogerq@kernel.org>,
	Tony Lindgren <tony@atomide.com>
Cc: Russell King <linux@armlinux.org.uk>, Pavel Machek <pavel@ucw.cz>,
	linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH] ARM: OMAP2+: Fix CPCAP node reference leaks
Date: Tue, 24 Nov 2026 15:10:06 +0000	[thread overview]
Message-ID: <20261124151012.333306-2-oss.patchbox@gmail.com> (raw)

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


                 reply	other threads:[~2026-11-24 15:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124151012.333306-2-oss.patchbox@gmail.com \
    --to=oss.patchbox@gmail.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=andreas@kemnade.info \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=pavel@ucw.cz \
    --cc=rogerq@kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox