mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ronald Claveau" <linux-kernel-dev@aliel.fr>
Cc: devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org,
	neil.armstrong@linaro.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks
Date: Wed, 23 Sep 2026 12:00:10 +0000	[thread overview]
Message-ID: <20260923120010.A03111F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260923-fix-t7-thermal-clock-v1-2-7d4c4682f182@aliel.fr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] thermal/amlogic: kernel panic on unclocked register access if DT lacks clocks
--

commit ea5439a5f68769e10d58c93a949a283bf6984a5f
Author: Ronald Claveau <linux-kernel-dev@aliel.fr>

thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks

The t7-thermal variant now exposes two clocks (bus and core) in its
devicetree binding, but the driver only knows how to get and manage
a single struct clk. Using devm_clk_get() would silently ignore the
second clock, so switch to devm_clk_bulk_get_all() and the matching
clk_bulk_prepare_enable()/clk_bulk_disable_unprepare() calls.

> diff --git a/drivers/thermal/amlogic_thermal.c b/drivers/thermal/amlogic_thermal.c
> index a0b530624b60c..2e8d042067079 100644
> --- a/drivers/thermal/amlogic_thermal.c
> +++ b/drivers/thermal/amlogic_thermal.c
[ ... ]
> @@ -323,9 +324,10 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
>  	if (IS_ERR(pdata->regmap))
>  		return PTR_ERR(pdata->regmap);
>  
> -	pdata->clk = devm_clk_get(dev, NULL);
> -	if (IS_ERR(pdata->clk))
> -		return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get clock\n");
> +	ret = devm_clk_bulk_get_all(dev, &pdata->clks);
> +	if (ret < 0)
> +		return dev_err_probe(dev, ret, "failed to get clocks\n");
> +	pdata->num_clks = ret;

[Severity: High]
Does this allow the probe to succeed without any clocks, leading to a crash
during register access if the device tree lacks clocks?

While device trees are typically trusted, missing required properties must
result in a graceful probe failure, not a system crash. The original
devm_clk_get() cleanly failed with -ENOENT if the clock was missing.

By changing this to devm_clk_bulk_get_all(), a missing clocks property now
returns 0. The driver sets pdata->num_clks = 0 and proceeds without error.

Later in probe, amlogic_thermal_enable() calls clk_bulk_prepare_enable()
(which becomes a no-op for 0 clocks) and then writes to TSENSOR_CFG_REG1.

Accessing hardware registers without first enabling the necessary bus or core
clocks usually results in a bus fault (synchronous external abort), causing a
kernel panic. Should there be an explicit check for ret == 0 to return an
error?

>  
>  	if (pdata->data->use_sm)
>  		ret = amlogic_thermal_probe_sm(pdev, pdata);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260923-fix-t7-thermal-clock-v1-0-7d4c4682f182@aliel.fr?part=2

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      reply	other threads:[~2026-09-23 12:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 11:51 [PATCH 0/2] Add bus clock for t7-thermal sensor Ronald Claveau via B4 Relay
2026-09-23 11:51 ` [PATCH 1/2] dt-bindings: thermal: amlogic: describe bus clock for t7-thermal Ronald Claveau via B4 Relay
2026-09-23 12:00   ` sashiko-bot
2026-09-23 12:02   ` Krzysztof Kozlowski
2026-09-23 12:17     ` linux-kernel-dev
2026-09-23 11:51 ` [PATCH 2/2] thermal/drivers/amlogic: switch to clk_bulk API to support multiple clocks Ronald Claveau via B4 Relay
2026-09-23 12:00   ` sashiko-bot [this message]

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=20260923120010.A03111F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-kernel-dev@aliel.fr \
    --cc=neil.armstrong@linaro.org \
    --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

all inboxes | Powered by JetHome®