All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ARM: OMAP2+: Hold reference returned from of_find_xxx API
@ 2022-09-16  2:08 Liang He
  0 siblings, 0 replies; only message in thread
From: Liang He @ 2022-09-16  2:08 UTC (permalink / raw)
  To: tony, linux, linux-omap; +Cc: windhl, chenmengda2009

In omap4_twl_init(), we should hold the reference returned from
of_find_compatible_node() which has increased the refcount and
then call of_node_put() with it when done.

Note that we should initialize 'np' with NULL, otherwise there
will be a bug to call of_node_put() with uninitialized 'np'
when cpu_is_omap44xx() is false.

Fixes: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
Co-developed-by: Mengda Chen <chenmengda2009@163.com>
Signed-off-by: Mengda Chen <chenmengda2009@163.com>
Signed-off-by: Liang He <windhl@126.com>
---

 v2: (1) initialize 'np' with NULL, advised by Russell King 
     (2) we use proper Co-developed-by tag based on kernel doc

 arch/arm/mach-omap2/omap_twl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index d4dab041324d..d56b33187244 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -213,10 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
 int __init omap4_twl_init(void)
 {
 	struct voltagedomain *voltdm;
+	struct device_node *np = NULL;
 
 	if (!cpu_is_omap44xx() ||
-	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
+	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
+		of_node_put(np);
 		return -ENODEV;
+	}
 
 	voltdm = voltdm_lookup("mpu");
 	omap_voltage_register_pmic(voltdm, &omap4_mpu_pmic);
-- 
2.25.1


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

only message in thread, other threads:[~2022-09-16  2:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16  2:08 [PATCH v2] ARM: OMAP2+: Hold reference returned from of_find_xxx API Liang He

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.