public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Morgan <macroalpha82@gmail.com>
To: Qiheng Lin <linqiheng@huawei.com>
Cc: sre@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: supply: Fix refcount leak in rk817_charger_probe
Date: Tue, 29 Nov 2022 11:35:45 -0600	[thread overview]
Message-ID: <638642f3.050a0220.8b7f1.d555@mx.google.com> (raw)
In-Reply-To: <20221128142740.1414-1-linqiheng@huawei.com>

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
> 

  reply	other threads:[~2022-11-29 17:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 14:27 [PATCH] power: supply: Fix refcount leak in rk817_charger_probe Qiheng Lin
2022-11-29 17:35 ` Chris Morgan [this message]
2022-12-03  1:23   ` Sebastian Reichel

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=638642f3.050a0220.8b7f1.d555@mx.google.com \
    --to=macroalpha82@gmail.com \
    --cc=linqiheng@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /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