All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: ti: pm33xx: Fix refcount leak in am33xx_pm_rtc_setup
@ 2022-05-16  7:41 ` Miaoqian Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-05-16  7:41 UTC (permalink / raw)
  To: Nishanth Menon, Santosh Shilimkar, Keerthy, Tony Lindgren,
	Dave Gerlach, linux-kernel, linux-arm-kernel
  Cc: linmq006

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] soc: ti: pm33xx: Fix refcount leak in am33xx_pm_rtc_setup
@ 2022-05-16  7:41 ` Miaoqian Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-05-16  7:41 UTC (permalink / raw)
  To: Nishanth Menon, Santosh Shilimkar, Keerthy, Tony Lindgren,
	Dave Gerlach, linux-kernel, linux-arm-kernel
  Cc: linmq006

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] soc: ti: pm33xx: Fix refcount leak in am33xx_pm_rtc_setup
  2022-05-16  7:41 ` Miaoqian Lin
@ 2022-06-18  0:28   ` Nishanth Menon
  -1 siblings, 0 replies; 4+ messages in thread
From: Nishanth Menon @ 2022-06-18  0:28 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Santosh Shilimkar, Keerthy, Tony Lindgren, linux-kernel,
	linux-arm-kernel

On 11:41-20220516, Miaoqian Lin wrote:
> 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")

Trouble here is that the patch wont apply directly on this commit ->
So, when we pass this over to stable, it will fail for certain stable
kernels, you want to explicitly list the stables on which this should
apply to.

Documentation/process/stable-kernel-rules.rst and be explicit in the
rules here.

[...]

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] soc: ti: pm33xx: Fix refcount leak in am33xx_pm_rtc_setup
@ 2022-06-18  0:28   ` Nishanth Menon
  0 siblings, 0 replies; 4+ messages in thread
From: Nishanth Menon @ 2022-06-18  0:28 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Santosh Shilimkar, Keerthy, Tony Lindgren, linux-kernel,
	linux-arm-kernel

On 11:41-20220516, Miaoqian Lin wrote:
> 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")

Trouble here is that the patch wont apply directly on this commit ->
So, when we pass this over to stable, it will fail for certain stable
kernels, you want to explicitly list the stables on which this should
apply to.

Documentation/process/stable-kernel-rules.rst and be explicit in the
rules here.

[...]

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-18  0:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16  7:41 [PATCH] soc: ti: pm33xx: Fix refcount leak in am33xx_pm_rtc_setup Miaoqian Lin
2022-05-16  7:41 ` Miaoqian Lin
2022-06-18  0:28 ` Nishanth Menon
2022-06-18  0:28   ` Nishanth Menon

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.