Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Claudiu Beznea" <claudiu.beznea+renesas@tuxon.dev>
Cc: "Vincent Mailhol" <mailhol@kernel.org>,
	devicetree@vger.kernel.org,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	conor+dt@kernel.org, "Marc Kleine-Budde" <mkl@pengutronix.de>,
	robh@kernel.org, linux-can@vger.kernel.org,
	wsa+renesas@sang-engineering.com,
	"Oliver Hartkopp" <socketcan@hartkopp.net>
Subject: Re: [PATCH 4/8] can: rcar_canfd: Allow the CAN FD clock to be sourced from fck
Date: Tue, 07 Jul 2026 10:33:28 +0000	[thread overview]
Message-ID: <20260707103329.3E9561F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260707102418.1646159-5-claudiu.beznea+renesas@tuxon.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Uninitialized variable usage when 'canfd' clock is missing on platforms where 'fcan_pclk' is 0.
--

--- Patch [4]: [PATCH 4/8] can: rcar_canfd: Allow the CAN FD clock to be sourced from fck ---
commit 0fffa3e660d5596983dd22ee45ce4eb746f70520
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

can: rcar_canfd: Allow the CAN FD clock to be sourced from fck

This commit adjusts the CAN FD clock handling in the R-Car CAN FD driver to
allow sourcing the clock from the peripheral clock (fck) for the RZ/G3S
platform, changing the "canfd" clock lookup to be optional.

Link: https://lore.kernel.org/all/1d9719e3-10ff-4cd8-b729-55fea93c37ce@wanadoo.fr

> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index b40ae5998c1da..6ec2d7a031238 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c

[ ... ]

> @@ -2190,13 +2196,18 @@ static int rcar_canfd_probe(struct platform_device *pdev)
>  	 */
>  	gpriv->can_clk = devm_clk_get(dev, "can_clk");
>  	if (IS_ERR(gpriv->can_clk) || (clk_get_rate(gpriv->can_clk) == 0)) {
> -		gpriv->can_clk = devm_clk_get(dev, "canfd");
> +		gpriv->can_clk = devm_clk_get_optional(dev, "canfd");
>  		if (IS_ERR(gpriv->can_clk))
>  			return dev_err_probe(dev, PTR_ERR(gpriv->can_clk),
>  					     "cannot get canfd clock\n");
>  
> +		if (gpriv->can_clk)
> +			fcan_freq = clk_get_rate(gpriv->can_clk);
> +		else if (info->fcan_pclk)
> +			fcan_freq = clk_get_rate(gpriv->clkp);
> +

[Severity: High]
Does this code leave fcan_freq uninitialized on legacy platforms if the device
tree is missing the "canfd" clock?

Because devm_clk_get_optional() returns NULL when the clock is missing,
gpriv->can_clk will be NULL. On platforms where info->fcan_pclk is 0, both
conditions in this if/else block evaluate to false.

>  		/* CANFD clock may be further divided within the IP */
> -		fcan_freq = clk_get_rate(gpriv->can_clk) / info->postdiv;
> +		fcan_freq /= info->postdiv;

If fcan_freq is uninitialized here, it will divide random stack memory and pass
that downstream to configure CAN bus bit timings. Should there be an error
returned if neither clock source is available?

>  	} else {
>  		fcan_freq = clk_get_rate(gpriv->can_clk);
>  		gpriv->extclk = gpriv->info->external_clk;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707102418.1646159-1-claudiu.beznea+renesas@tuxon.dev?part=4

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

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 10:24 [PATCH 0/8] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
2026-07-07 10:24 ` [PATCH 1/8] clk: r9a08g045-cpg: Add clocks and resets for CAN-FD Claudiu Beznea
2026-07-07 10:34   ` sashiko-bot
2026-07-09 15:45   ` Geert Uytterhoeven
2026-07-07 10:24 ` [PATCH 2/8] dt-bindings: can: renesas,rcar-canfd: Document RZ/G3S SoC Claudiu Beznea
2026-07-07 10:30   ` sashiko-bot
2026-07-07 16:15     ` Conor Dooley
2026-07-07 16:16   ` Conor Dooley
2026-07-07 10:24 ` [PATCH 3/8] can: rcar_canfd: Fix typos in macro names Claudiu Beznea
2026-07-07 10:24 ` [PATCH 4/8] can: rcar_canfd: Allow the CAN FD clock to be sourced from fck Claudiu Beznea
2026-07-07 10:33   ` sashiko-bot [this message]
2026-07-07 10:24 ` [PATCH 5/8] can: rcar_canfd: Do not set registers selecting the CAN mode Claudiu Beznea
2026-07-07 10:53   ` sashiko-bot
2026-07-07 10:24 ` [PATCH 6/8] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
2026-07-07 10:49   ` sashiko-bot
2026-07-07 10:24 ` [PATCH 7/8] arm64: dts: renesas: r9a08g045: Add CAN-FD node Claudiu Beznea
2026-07-07 10:24 ` [PATCH 8/8] arm64: dts: renesas: rzg3s-smarc: Enable CAN-FD Claudiu Beznea
2026-07-07 10:31 ` [PATCH 0/8] can: rcar_canfd: Add support for Renesas RZ/G3S Biju Das

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=20260707103329.3E9561F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=claudiu.beznea+renesas@tuxon.dev \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=socketcan@hartkopp.net \
    --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