linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: supply: Fix refcount leak in rk817_charger_probe
@ 2022-11-28 14:27 Qiheng Lin
  2022-11-29 17:35 ` Chris Morgan
  0 siblings, 1 reply; 3+ messages in thread
From: Qiheng Lin @ 2022-11-28 14:27 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, Qiheng Lin

of_get_child_by_name() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: 11cb8da0189b ("power: supply: Add charger driver for Rockchip RK817")
Signed-off-by: Qiheng Lin <linqiheng@huawei.com>
---
 drivers/power/supply/rk817_charger.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
index 635f051b0821..d25a81d79fac 100644
--- a/drivers/power/supply/rk817_charger.c
+++ b/drivers/power/supply/rk817_charger.c
@@ -1060,8 +1060,10 @@ static int rk817_charger_probe(struct platform_device *pdev)
 		return -ENODEV;

 	charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
-	if (!charger)
+	if (!charger) {
+		of_node_put(node);
 		return -ENOMEM;
+	}

 	charger->rk808 = rk808;

--
2.32.0


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

* Re: [PATCH] power: supply: Fix refcount leak in rk817_charger_probe
  2022-11-28 14:27 [PATCH] power: supply: Fix refcount leak in rk817_charger_probe Qiheng Lin
@ 2022-11-29 17:35 ` Chris Morgan
  2022-12-03  1:23   ` Sebastian Reichel
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Morgan @ 2022-11-29 17:35 UTC (permalink / raw)
  To: Qiheng Lin; +Cc: sre, linux-pm, linux-kernel

On Mon, Nov 28, 2022 at 10:27:40PM +0800, Qiheng Lin wrote:
> of_get_child_by_name() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
> 
> Fixes: 11cb8da0189b ("power: supply: Add charger driver for Rockchip RK817")
> Signed-off-by: Qiheng Lin <linqiheng@huawei.com>

Good catch, thank you!

Reviewed-by: Chris Morgan <macromorgan@hotmail.com>

> ---
>  drivers/power/supply/rk817_charger.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
> index 635f051b0821..d25a81d79fac 100644
> --- a/drivers/power/supply/rk817_charger.c
> +++ b/drivers/power/supply/rk817_charger.c
> @@ -1060,8 +1060,10 @@ static int rk817_charger_probe(struct platform_device *pdev)
>  		return -ENODEV;
> 
>  	charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
> -	if (!charger)
> +	if (!charger) {
> +		of_node_put(node);
>  		return -ENOMEM;
> +	}
> 
>  	charger->rk808 = rk808;
> 
> --
> 2.32.0
> 

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

* Re: [PATCH] power: supply: Fix refcount leak in rk817_charger_probe
  2022-11-29 17:35 ` Chris Morgan
@ 2022-12-03  1:23   ` Sebastian Reichel
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2022-12-03  1:23 UTC (permalink / raw)
  To: Chris Morgan; +Cc: Qiheng Lin, linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]

Hi,

On Tue, Nov 29, 2022 at 11:35:45AM -0600, Chris Morgan wrote:
> On Mon, Nov 28, 2022 at 10:27:40PM +0800, Qiheng Lin wrote:
> > of_get_child_by_name() returns a node pointer with refcount
> > incremented, we should use of_node_put() on it when not need anymore.
> > Add missing of_node_put() to avoid refcount leak.
> > 
> > Fixes: 11cb8da0189b ("power: supply: Add charger driver for Rockchip RK817")
> > Signed-off-by: Qiheng Lin <linqiheng@huawei.com>
> 
> Good catch, thank you!
> 
> Reviewed-by: Chris Morgan <macromorgan@hotmail.com>

Thanks, merged.

-- Sebastian

> > ---
> >  drivers/power/supply/rk817_charger.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c
> > index 635f051b0821..d25a81d79fac 100644
> > --- a/drivers/power/supply/rk817_charger.c
> > +++ b/drivers/power/supply/rk817_charger.c
> > @@ -1060,8 +1060,10 @@ static int rk817_charger_probe(struct platform_device *pdev)
> >  		return -ENODEV;
> > 
> >  	charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
> > -	if (!charger)
> > +	if (!charger) {
> > +		of_node_put(node);
> >  		return -ENOMEM;
> > +	}
> > 
> >  	charger->rk808 = rk808;
> > 
> > --
> > 2.32.0
> > 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-12-03  1:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-28 14:27 [PATCH] power: supply: Fix refcount leak in rk817_charger_probe Qiheng Lin
2022-11-29 17:35 ` Chris Morgan
2022-12-03  1:23   ` Sebastian Reichel

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).