All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Miquel Raynal" <miquel.raynal@bootlin.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
	linux-clk@vger.kernel.org
Subject: Re: [PATCH v7 5/7] clk: nuvoton: ma35d1: Reparent SYSPLL correctly
Date: Sat, 03 Oct 2026 01:33:06 +0000	[thread overview]
Message-ID: <20261003013306.D8DB41F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261002-perso-ma35d1-upstream-clk-v7-5-cbd991fa6270@bootlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] clk: buffer overflow via zero-length syspll_parent_data array
- [High] clk: unhandled ERR_PTR dereference in syspll_parent_data
--

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

clk: nuvoton: ma35d1: Reparent SYSPLL correctly

The clock tree is still incorrect. SYSPLL is derived from HXT_GATE, very
much like CAPLL, DDRPLL, VPLL, APLL and EPLL. SYSPLL has a fixed
frequency, but if HXT gets gated, SYSPLL stops running.

> diff --git a/drivers/clk/nuvoton/clk-ma35d1.c b/drivers/clk/nuvoton/clk-ma35d1.c
> index 2e6e1c65d01e5..0baaa93f13805 100644
> --- a/drivers/clk/nuvoton/clk-ma35d1.c
> +++ b/drivers/clk/nuvoton/clk-ma35d1.c
> @@ -73,6 +73,8 @@ static const struct clk_parent_data lxtg_parent_data[] = {
>  	{ .fw_name = "lxt", .name = "lxt" },
>  };
>  
> +static struct clk_parent_data syspll_parent_data[] = {};
> +

[Severity: Critical]
Does this code allocate a zero-length array in the .bss section?

Later in ma35d1_clocks_probe(), there is an unconditional write to
syspll_parent_data[0].hw, which seems to write entirely out-of-bounds
and corrupt 8 bytes of adjacent static memory.

[ ... ]

> @@ -275,22 +283,23 @@ static int ma35d1_clocks_probe(struct platform_device *pdev)
>  
>  	/* Old DTs do not describe the low-speed crystal */
>  	if (num_clks == 1)
> -		hws[LXT] = ma35d1_clk_fixed("lxt", 32768);
> +		hws[LXT] = ma35d1_clk_fixed(dev, "lxt", 32768);
>  
>  	hws[HXT_GATE] = ma35d1_clk_gate_parent_data(dev, "hxt_gate", hxtg_parent_data,
>  						    clk_base + REG_CLK_PWRCTL, 0);

[ ... ]

>  	hws[CAPLL] = ma35d1_reg_clk_pll(dev, CAPLL, pllmode[0], "capll",
>  					hws[HXT_GATE], clk_base + REG_CLK_PLL0CTL0);
> -	hws[SYSPLL] = ma35d1_clk_fixed("syspll", 180000000);
> +	syspll_parent_data[0].hw = hws[HXT_GATE];
> +	hws[SYSPLL] = ma35d1_clk_fixed_parent_data(dev, "syspll", 180000000, syspll_parent_data);

[Severity: High]
If ma35d1_clk_gate_parent_data() fails when allocating hws[HXT_GATE],
it returns an ERR_PTR. Could this ERR_PTR be blindly assigned to
syspll_parent_data[0].hw and registered via ma35d1_clk_fixed_parent_data()?

Without validating the pointer with IS_ERR(), the common clock framework
might dereference this ERR_PTR in clk_core_fill_parent_index() causing
a kernel panic.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261002-perso-ma35d1-upstream-clk-v7-0-cbd991fa6270@bootlin.com?part=5

  reply	other threads:[~2026-10-03  1:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 15:01 [PATCH v7 0/7] clk: nuvoton: ma35d1: Fix mux parenting and peripheral clock rates Miquel Raynal
2026-10-02 15:01 ` [PATCH v7 1/7] clk: nuvoton: ma35d1: Use clk_hw pointers as mux parents Miquel Raynal
2026-10-02 15:01 ` [PATCH v7 2/7] clk: nuvoton: ma35d1: Avoid possible error pointer dereferencing Miquel Raynal
2026-10-02 15:01 ` [PATCH v7 3/7] clk: nuvoton: ma35d1: Retrieve HXT/LXT from DT when possible Miquel Raynal
2026-10-02 15:01 ` [PATCH v7 4/7] clk: nuvoton: ma35d1: Reparent the gates correctly Miquel Raynal
2026-10-02 15:01 ` [PATCH v7 5/7] clk: nuvoton: ma35d1: Reparent SYSPLL correctly Miquel Raynal
2026-10-03  1:33   ` sashiko-bot [this message]
2026-10-02 15:01 ` [PATCH v7 6/7] arm64: dts: nuvoton: ma35d1: Drop HXT clock output name Miquel Raynal
2026-10-02 15:01 ` [PATCH v7 7/7] 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=20261003013306.D8DB41F000FF@smtp.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.