All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Miquel Raynal" <miquel.raynal@bootlin.com>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v9 05/10] clk: nuvoton: ma35d1: Use device managed helpers for fixed rate clocks
Date: Thu, 15 Oct 2026 12:32:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-172803@kernel.org> (raw)
In-Reply-To: <20261015-perso-ma35d1-upstream-clk-v9-5-1f548fa2002e@bootlin.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] clk: nuvoton: UAF on unbind due to unmanaged mux clocks holding devm-managed parents
--

commit cdff8376e12bb7360642c4498d1f771077f9d948
Author: Miquel Raynal <miquel.raynal@bootlin.com>

clk: nuvoton: ma35d1: Use device managed helpers for fixed rate clocks

Most of the clocks are already registered with device managed helpers,
except the fixed clocks. Harmonize the driver by using the already
available managed helper for that.

> diff --git a/drivers/clk/nuvoton/clk-ma35d1.c b/drivers/clk/nuvoton/clk-ma35d1.c
> index 75b7e2a84bfd9..4a745b169778d 100644
> --- a/drivers/clk/nuvoton/clk-ma35d1.c
> +++ b/drivers/clk/nuvoton/clk-ma35d1.c
> @@ -139,9 +139,9 @@ static const struct clk_div_table eadc_div_table[] = {
>  	{13, 28}, {14, 30}, {15, 32}, {0, 0},
>  };
>  
> -static struct clk_hw *ma35d1_clk_fixed(const char *name, int rate)
> +static struct clk_hw *ma35d1_clk_fixed(struct device *dev, const char *name, int rate)
>  {
> -	return clk_hw_register_fixed_rate(NULL, name, NULL, 0, rate);
> +	return devm_clk_hw_register_fixed_rate(dev, name, NULL, 0, rate);

[Severity: High]
Does this change introduce a use-after-free on driver unbind?

Mux clocks in this driver are registered using clk_hw_register_mux_hws() in
ma35d1_clk_mux(), which is not devm-managed:

drivers/clk/nuvoton/clk-ma35d1.c:ma35d1_clk_mux() {
...
	return clk_hw_register_mux_hws(dev, name, parent_hws, num_parents,
				       CLK_SET_RATE_NO_REPARENT, reg, shift,
				       width, 0, &ma35d1_lock);
}

Because these mux clocks are not devm-managed, they will remain in the clock
framework after probe failure or driver unbind. Since this patch makes their
fixed-rate parent clocks devm-managed, those parents will now be freed on
unbind.

Will the orphaned mux clocks retain dangling pointers to the freed fixed-rate
parents, causing a use-after-free if the clock tree is traversed later (e.g.,
via /sys/kernel/debug/clk/clk_possible_parents)?

>  }
>  
>  static struct clk_hw *ma35d1_clk_mux(struct device *dev, const char *name,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-perso-ma35d1-upstream-clk-v9-0-1f548fa2002e@bootlin.com?part=5

  reply	other threads:[~2026-10-15 12:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 12:18 [PATCH v9 00/10] clk: nuvoton: ma35d1: Fix mux parenting and peripheral clock rates Miquel Raynal
2026-10-15 12:18 ` [PATCH v9 01/10] clk: nuvoton: ma35d1: Use clk_hw pointers as mux parents Miquel Raynal
2026-10-15 12:34   ` sashiko-bot
2026-10-15 12:57     ` Miquel Raynal
2026-10-15 12:18 ` [PATCH v9 02/10] clk: nuvoton: ma35d1: Avoid possible error pointer dereferencing Miquel Raynal
2026-10-15 12:18 ` [PATCH v9 03/10] clk: nuvoton: ma35d1: Retrieve HXT/LXT from DT when possible Miquel Raynal
2026-10-15 12:19 ` [PATCH v9 04/10] clk: nuvoton: ma35d1: Reparent the gates correctly Miquel Raynal
2026-10-15 12:19 ` [PATCH v9 05/10] clk: nuvoton: ma35d1: Use device managed helpers for fixed rate clocks Miquel Raynal
2026-10-15 12:32   ` sashiko-bot [this message]
2026-10-15 12:19 ` [PATCH v9 06/10] clk: Create devm_clk_hw_register_fixed_rate_parent_hw() Miquel Raynal
2026-10-15 12:19 ` [PATCH v9 07/10] clk: nuvoton: ma35d1: Reparent SYSPLL correctly Miquel Raynal
2026-10-15 12:19 ` [PATCH v9 08/10] MAINTAINERS: Add myself as Nuvoton MA35D1 clock controller Miquel Raynal
2026-10-15 12:19 ` [PATCH v9 09/10] arm64: dts: nuvoton: ma35d1: Drop HXT clock output name Miquel Raynal
2026-10-15 12:19 ` [PATCH v9 10/10] arm64: dts: nuvoton: ma35d1: Add LXT crystal and clock-names Miquel Raynal

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-172803@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.