Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geert Uytterhoeven" <geert+renesas@glider.be>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org,
	wsa+renesas@sang-engineering.com
Subject: Re: [PATCH v4 4/8] reset: Add reset_control_get_from_provider_exclusive()
Date: Fri, 16 Oct 2026 16:02:41 +0000	[thread overview]
Message-ID: <sashiko-outbox-174595@kernel.org> (raw)
In-Reply-To: <b9e68c8df1e545191e0359dba23fe53de31a4ce5.1792163045.git.geert+renesas@glider.be>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] of: memory leak of device node reference on error path
--

commit 6e1c5e27c808997c3ce5fe5fc257fedbfabb6954
Author: Geert Uytterhoeven <geert+renesas@glider.be>

reset: Add reset_control_get_from_provider_exclusive()

This patch introduces reset_control_get_from_provider_exclusive() to allow
looking up and obtaining an exclusive reference to a reset controller from
a provider. It modifies the existing __reset_control_get_from_provider()
helper to support this lookup.

> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 0e11f4c81c10d..421bcc4c89cc2 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -1153,18 +1154,30 @@ __reset_control_get_from_provider(const struct fwnode_reference_args *args,
>  	if (WARN_ON(args->nargs != rcdev->fwnode_reset_n_cells))
>  		return ERR_PTR(-EINVAL);
>  
> -	if (rcdev->of_xlate && is_of_node(consumer)) {
> -		struct device_node *np = to_of_node(consumer);
> +	if (rcdev->of_xlate && is_of_node(fwnode)) {
> +		struct device_node *np = to_of_node(fwnode);
>  		struct of_phandle_args of_args;
>  		int ret;
>  
> -		ret = of_parse_phandle_with_args(np,
> +		if (consumer) {
> +			ret = of_parse_phandle_with_args(np,
>  					 gpio_fallback ? "reset-gpios" : "resets",
>  					 gpio_fallback ? "#gpio-cells" : "#reset-cells",
>  					 gpio_fallback ? 0 : index,
>  					 &of_args);
> -		if (ret)
> -			return ERR_PTR(ret);
> +			if (ret)
> +				return ERR_PTR(ret);
> +		} else {
> +			of_args.np = of_node_get(np);
> +			of_args.args_count = args->nargs;
> +
> +			for (unsigned int i = 0; i < args->nargs; i++) {
> +				if (args->args[i] > U32_MAX)
> +					return ERR_PTR(-EINVAL);

[Severity: Medium]
Will this leak the device node reference acquired above?

When consumer is NULL in __reset_control_get_from_provider(), the code
acquires a device node reference via of_args.np = of_node_get(np).

If an argument exceeds U32_MAX, the function immediately returns
ERR_PTR(-EINVAL). This early return skips the of_node_put(of_args.np) call
at the end of the block, permanently leaking the OF node reference count.

> +
> +				of_args.args[i] = args->args[i];
> +			}
> +		}
>  
>  		rstc_id = rcdev->of_xlate(rcdev, &of_args);
>  		of_node_put(of_args.np);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792163045.git.geert+renesas@glider.be?part=4

  reply	other threads:[~2026-10-16 16:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 15:55 [PATCH v4 0/8] R-Car X5H Ironhide CPG/MDLC SCMI remapping support Geert Uytterhoeven
2026-10-16 15:55 ` [PATCH v4 1/8] clk: renesas: r8a78000: Add clk_hw to clk_map Geert Uytterhoeven
2026-10-16 15:55 ` [PATCH v4 2/8] clk: renesas: r8a78000: Add SCMI remapping support Geert Uytterhoeven
2026-10-16 16:13   ` sashiko-bot
2026-10-16 16:17     ` Geert Uytterhoeven
2026-10-16 15:55 ` [PATCH v4 3/8] reset: Extract __reset_control_get_from_provider() Geert Uytterhoeven
2026-10-16 15:55 ` [PATCH v4 4/8] reset: Add reset_control_get_from_provider_exclusive() Geert Uytterhoeven
2026-10-16 16:02   ` sashiko-bot [this message]
2026-10-16 16:08     ` Geert Uytterhoeven
2026-10-16 15:55 ` [PATCH v4 5/8] pmdomain: Make genpd_get_from_provider() return -EPROBE_DEFER Geert Uytterhoeven
2026-10-16 16:09   ` sashiko-bot
2026-10-16 15:55 ` [PATCH v4 6/8] pmdomain: Make genpd_get_from_provider() public Geert Uytterhoeven
2026-10-16 16:08   ` sashiko-bot
2026-10-16 15:55 ` [PATCH v4 7/8] pmdomain: renesas: r8a78000: Add SCMI remapping support Geert Uytterhoeven
2026-10-16 16:15   ` sashiko-bot
2026-10-16 15:55 ` [PATCH v4 8/8] arm64: dts: renesas: ironhide: Enable SCMI devpd, sys, clock, and reset Geert Uytterhoeven

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=sashiko-outbox-174595@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=linux-clk@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.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