Linux Power Management development
 help / color / mirror / Atom feed
From: "Diederik de Haas" <diederik@cknow-tech.com>
To: "Shawn Lin" <shawn.lin@rock-chips.com>,
	"Ulf Hansson" <ulfh@kernel.org>,
	"Heiko Stuebner" <heiko@sntech.de>
Cc: "Sebastian Reichel" <sebastian.reichel@collabora.com>,
	<linux-pm@vger.kernel.org>, <linux-rockchip@lists.infradead.org>
Subject: Re: [PATCH v2 2/4] pmdomain: rockchip: fix clock leak on domain probe failure
Date: Sat, 19 Sep 2026 19:03:22 +0200	[thread overview]
Message-ID: <DLJGENL5TFXO.TT10VQFGVB8S@cknow-tech.com> (raw)
In-Reply-To: <1789778111-173149-3-git-send-email-shawn.lin@rock-chips.com>

On Sat Sep 19, 2026 at 2:35 AM CEST, Shawn Lin wrote:
> When of_clk_get() failed in the middle of the loop, the references of
> the clocks acquired so far were leaked instead of being released by
> the error path.
>
> Also switch the clks array allocation from devm_kcalloc() to
> devm_kzalloc() so that clk_bulk_put() cannot run over uninitialized
> entries.
>
> Fixes: d909072d0521 ("soc: rockchip: power-domain: use clk_bulk APIs")
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>
> Changes in v2:
> - switch to use devm_kzalloc()
> - add Sebastian's tag
>
>  drivers/pmdomain/rockchip/pm-domains.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index 068dd4b3..43fdb7f 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -825,7 +825,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
>  
>  	pd->num_clks = of_clk_get_parent_count(node);
>  	if (pd->num_clks > 0) {
> -		pd->clks = devm_kcalloc(pmu->dev, pd->num_clks,
> +		pd->clks = devm_kzalloc(pmu->dev, pd->num_clks,
>  					sizeof(*pd->clks), GFP_KERNEL);

/media/nvme/dev/debian/salsa/kernel-team/linux/drivers/pmdomain/rockchip/pm-domains.c: In function ‘rockchip_pm_add_one_domain’:
/media/nvme/dev/debian/salsa/kernel-team/linux/drivers/pmdomain/rockchip/pm-domains.c:840:28: error: too many arguments to function ‘devm_kzalloc’; expected 3, have 4
  840 |                 pd->clks = devm_kzalloc(pmu->dev, pd->num_clks,
      |                            ^~~~~~~~~~~~
In file included from /media/nvme/dev/debian/salsa/kernel-team/linux/include/linux/device.h:31,
                 from /media/nvme/dev/debian/salsa/kernel-team/linux/include/linux/platform_device.h:13,
                 from /media/nvme/dev/debian/salsa/kernel-team/linux/drivers/pmdomain/rockchip/pm-domains.c:13:
/media/nvme/dev/debian/salsa/kernel-team/linux/include/linux/device/devres.h:48:21: note: declared here
   48 | static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
      |                     ^~~~~~~~~~~~

Seems legit:
https://elixir.bootlin.com/linux/v7.3-rc3/source/include/linux/device/devres.h#L48

Cheers,
  Diederik

>  		if (!pd->clks)
>  			return -ENOMEM;
> @@ -842,7 +842,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
>  			dev_err(pmu->dev,
>  				"%pOFn: failed to get clk at index %d: %d\n",
>  				node, i, error);
> -			return error;
> +			goto err_put_clocks;
>  		}
>  	}
>  



  reply	other threads:[~2026-09-19 17:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19  0:35 [PATCH v2 0/4] Small fixes and improvement for Rockchip pm-domains driver Shawn Lin
2026-09-19  0:35 ` [PATCH v2 1/4] pmdomain: rockchip: propagate subdomain add errors Shawn Lin
2026-09-19  0:35 ` [PATCH v2 2/4] pmdomain: rockchip: fix clock leak on domain probe failure Shawn Lin
2026-09-19 17:03   ` Diederik de Haas [this message]
2026-09-19  0:35 ` [PATCH v2 3/4] pmdomain: rockchip: don't ignore clock lookup errors on attach Shawn Lin
2026-09-19  0:35 ` [PATCH v2 4/4] pmdomain: rockchip: drop duplicated errno from supply failure message Shawn Lin

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=DLJGENL5TFXO.TT10VQFGVB8S@cknow-tech.com \
    --to=diederik@cknow-tech.com \
    --cc=heiko@sntech.de \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=shawn.lin@rock-chips.com \
    --cc=ulfh@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