Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Miquel Raynal" <miquel.raynal@bootlin.com>
Cc: linux-clk@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v3 4/6] clk: nuvoton: ma35d1: Add missing WDT/WWDT parent clocks
Date: Fri, 25 Sep 2026 14:57:01 +0000	[thread overview]
Message-ID: <20260925145701.6ACF51F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260925-perso-ma35d1-upstream-clk-v3-4-ffbae7e020a8@bootlin.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] clk: nuvoton: ma35d1: heap buffer overflow when assigning WDT/WWDT parent clocks
--

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

clk: nuvoton: ma35d1: Add missing WDT/WWDT parent clocks

This commit adds missing WDT and WWDT parent clocks for the Nuvoton MA35D1
clock controller. It registers pclk3_div4096 and pclk4_div4096 as fixed
factor children of pclk3 and pclk4 to expose them through the provider.

Link: https://lore.kernel.org/linux-clk/b8a8a65b-e302-4747-bc90-4920fc48795a@gmail.com/

> diff --git a/drivers/clk/nuvoton/clk-ma35d1.c b/drivers/clk/nuvoton/clk-ma35d1.c
> index 6aa42a3e1be3b..5d706f5c30a59 100644
> --- a/drivers/clk/nuvoton/clk-ma35d1.c
> +++ b/drivers/clk/nuvoton/clk-ma35d1.c
> @@ -544,6 +544,8 @@ static int ma35d1_clocks_probe(struct platform_device *pdev)
>  	hws[HCLK3] = ma35d1_clk_fixed_factor(dev, "hclk3", "sysclk1_mux", 1, 2);
>  	hws[PCLK3] = ma35d1_clk_fixed_factor(dev, "pclk3", "sysclk1_mux", 1, 2);
>  	hws[PCLK4] = ma35d1_clk_fixed_factor(dev, "pclk4", "sysclk1_mux", 1, 2);
> +	hws[PCLK3_DIV4096] = ma35d1_clk_fixed_factor(dev, "pclk3_div4096", "pclk3", 1, 4096);
> +	hws[PCLK4_DIV4096] = ma35d1_clk_fixed_factor(dev, "pclk4_div4096", "pclk4", 1, 4096);

[Severity: High]
Does this code overflow the hws[] array?

Looking at the definitions in drivers/clk/nuvoton/clk-ma35d1.c,
MA35D1_CLK_COUNT is defined as 236:

#define MA35D1_CLK_COUNT 236

And in ma35d1_clocks_probe(), the array is allocated using this count:

	ma35d1_hw_data = devm_kzalloc(dev,
				      struct_size(ma35d1_hw_data, hws, MA35D1_CLK_COUNT),
				      GFP_KERNEL);
	if (!ma35d1_hw_data)
		return -ENOMEM;

	ma35d1_hw_data->num = MA35D1_CLK_COUNT;
	hws = ma35d1_hw_data->hws;

Since the hardcoded MA35D1_CLK_COUNT was not increased to accommodate the
two newly added clocks, will writing to PCLK3_DIV4096 (236) and
PCLK4_DIV4096 (237) cause an out-of-bounds heap write?

Additionally, because ma35d1_hw_data->num remains capped at
MA35D1_CLK_COUNT, does this leave the new clocks unregistered to external
dt-binding consumers?

>  
>  	hws[USBPHY0] = ma35d1_clk_fixed("usbphy0", 480000000);
>  	hws[USBPHY1] = ma35d1_clk_fixed("usbphy1", 480000000);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260925-perso-ma35d1-upstream-clk-v3-0-ffbae7e020a8@bootlin.com?part=4

  reply	other threads:[~2026-09-25 14:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 14:44 [PATCH v3 0/6] clk: nuvoton: ma35d1: Fix mux parenting and peripheral clock rates Miquel Raynal
2026-09-25 14:44 ` [PATCH v3 1/6] clk: nuvoton: ma35d1: Keep the clock count in the driver Miquel Raynal
2026-09-25 14:44 ` [PATCH v3 2/6] dt-bindings: clock: ma35d1: Drop CLK_MAX_IDX define Miquel Raynal
2026-09-25 14:44 ` [PATCH v3 3/6] dt-bindings: clock: ma35d1: Add missing WDT/WWDT parent clocks Miquel Raynal
2026-09-25 14:55   ` sashiko-bot
2026-09-25 14:44 ` [PATCH v3 4/6] clk: nuvoton: " Miquel Raynal
2026-09-25 14:57   ` sashiko-bot [this message]
2026-09-25 15:06     ` Miquel Raynal
2026-09-25 14:44 ` [PATCH v3 5/6] clk: nuvoton: ma35d1: Use clk_hw pointers as mux parents Miquel Raynal
2026-09-25 14:44 ` [PATCH v3 6/6] clk: nuvoton: ma35d1: Avoid possible error pointer dereferencing 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=20260925145701.6ACF51F00893@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox