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 01/10] clk: nuvoton: ma35d1: Use clk_hw pointers as mux parents
Date: Thu, 15 Oct 2026 12:34:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-172810@kernel.org> (raw)
In-Reply-To: <20261015-perso-ma35d1-upstream-clk-v9-1-1f548fa2002e@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] clk: ma35d1: unmanaged mux clocks leak and cause UAF on probe failure
--
commit ccf1a8c0da3e763270d5ce7fb63fab6388c0c310
Author: Miquel Raynal <miquel.raynal@bootlin.com>
clk: nuvoton: ma35d1: Use clk_hw pointers as mux parents
This commit updates the MA35D1 clock provider to use actual hardware clocks
as mux parents rather than relying on parent data structures. This resolves
an issue where parent lookups failed, leading to an incorrect, flat clock
tree and missing rate assignments.
> diff --git a/drivers/clk/nuvoton/clk-ma35d1.c b/drivers/clk/nuvoton/clk-ma35d1.c
> --- a/drivers/clk/nuvoton/clk-ma35d1.c
> +++ b/drivers/clk/nuvoton/clk-ma35d1.c
[ ... ]
> static struct clk_hw *ma35d1_clk_mux(struct device *dev, const char *name,
> void __iomem *reg, u8 shift, u8 width,
> - const struct clk_parent_data *pdata,
> - int num_pdata)
> + struct clk_hw **hws,
> + const int *parent_idx, int num_parents)
> {
> - return clk_hw_register_mux_parent_data(dev, name, pdata, num_pdata,
> - CLK_SET_RATE_NO_REPARENT, reg, shift,
> - width, 0, &ma35d1_lock);
> + const struct clk_hw *parent_hws[MA35D1_MUX_MAX_PARENTS] = {};
> + int i;
> +
> + for (i = 0; i < num_parents; i++)
> + parent_hws[i] = (parent_idx[i] >= 0) ? hws[parent_idx[i]] : NULL;
> +
> + return clk_hw_register_mux_hws(dev, name, parent_hws, num_parents,
> + CLK_SET_RATE_NO_REPARENT, reg, shift,
> + width, 0, &ma35d1_lock);
> }
[Severity: High]
If device probe fails after these muxes are registered (for example, if
devm_of_clk_add_hw_provider() returns -ENOMEM near the end of
ma35d1_clocks_probe()), the devres subsystem will unwind managed allocations,
unmap clk_base, and free ma35d1_hw_data.
Since the mux clocks registered here using clk_hw_register_mux_hws() are
unmanaged, won't they remain registered in the clock core and permanently
leak their internal struct clk_mux allocations?
Furthermore, because they remain registered, could subsequent clock
interactions dereference the now-unmapped clk_base register pointers,
causing a use-after-free or unmapped memory access?
While a later patch in this series addresses a similar issue for fixed clocks
by switching to a devm_ variant, ma35d1_clk_mux() still uses the unmanaged
clk_hw_register_mux_hws(). Should this be updated to use the appropriate
managed devm_ variant to prevent this regression?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-perso-ma35d1-upstream-clk-v9-0-1f548fa2002e@bootlin.com?part=1
next prev parent reply other threads:[~2026-10-15 12:34 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 [this message]
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
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-172810@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox