From: Miaoqian Lin <linmq006@gmail.com>
To: Nishanth Menon <nm@ti.com>,
Santosh Shilimkar <ssantosh@kernel.org>,
Keerthy <j-keerthy@ti.com>, Tony Lindgren <tony@atomide.com>,
Dave Gerlach <d-gerlach@ti.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: linmq006@gmail.com
Subject: [PATCH] soc: ti: pm33xx: Fix refcount leak in am33xx_pm_rtc_setup
Date: Mon, 16 May 2022 11:41:00 +0400 [thread overview]
Message-ID: <20220516074100.30599-1-linmq006@gmail.com> (raw)
of_find_node_by_name() returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
Add missing of_node_put() to avoid refcount leak.
Fixes: 5a99ae0092fe ("soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/soc/ti/pm33xx.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c
index 7bab4bbaf02d..b4d6e6ad85f4 100644
--- a/drivers/soc/ti/pm33xx.c
+++ b/drivers/soc/ti/pm33xx.c
@@ -445,8 +445,10 @@ static int am33xx_pm_rtc_setup(void)
if (of_device_is_available(np)) {
/* RTC interconnect target module clock */
rtc_fck = of_clk_get_by_name(np->parent, "fck");
- if (IS_ERR(rtc_fck))
- return PTR_ERR(rtc_fck);
+ if (IS_ERR(rtc_fck)) {
+ error = PTR_ERR(rtc_fck);
+ goto err_node_put;
+ }
rtc_base_virt = of_iomap(np, 0);
if (!rtc_base_virt) {
@@ -479,6 +481,7 @@ static int am33xx_pm_rtc_setup(void)
} else {
pr_warn("PM: no-rtc available, rtc-only mode disabled.\n");
}
+ of_node_put(np);
return 0;
@@ -486,7 +489,8 @@ static int am33xx_pm_rtc_setup(void)
iounmap(rtc_base_virt);
err_clk_put:
clk_put(rtc_fck);
-
+err_node_put:
+ of_node_put(np);
return error;
}
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-05-16 7:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 7:41 Miaoqian Lin [this message]
2022-06-18 0:28 ` [PATCH] soc: ti: pm33xx: Fix refcount leak in am33xx_pm_rtc_setup Nishanth Menon
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=20220516074100.30599-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=d-gerlach@ti.com \
--cc=j-keerthy@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nm@ti.com \
--cc=ssantosh@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;
as well as URLs for NNTP newsgroup(s).