mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Yaohan Li <shunsheng1218@gmail.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] thermal: rcar_gen3: check for sensors before reading the fuses
Date: Thu, 26 Nov 2026 12:58:06 +0100	[thread overview]
Message-ID: <20261126115806.GN3898744@ragnatech.se> (raw)
In-Reply-To: <20261126013626.2168810-1-shunsheng1218@gmail.com>

Hi Yaohan,

Thanks for your work and persistence.

On 2026-11-26 09:36:26 +0800, Yaohan Li wrote:
> rcar_gen3_thermal_read_fuses() reads the THSCP register through the
> first TSC. If the device has no TSC resources, priv->tscs[0] is NULL,
> and the read causes a NULL pointer dereference.
> 
> Before hardware calibration support was added, leaving the
> !priv->num_tscs check at the end of probe was safe because TSCs were
> only accessed inside loops over the discovered sensors.
> rcar_gen3_thermal_read_fuses() introduced an unconditional access to
> priv->tscs[0] before that check.
> 
> Move the existing zero-TSC check right after discovering the sensors,
> before reading the calibration fuses.
> 
> Fixes: c3131bd5586d ("thermal: rcar_gen3_thermal: Read calibration from hardware")
> Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
> Changes since v4 (split out from the withdrawn 3-patch series):
>   - Split out as a standalone single patch per Niklas Söderlund's feedback
>     (<20261125060429.GK3898744@ragnatech.se>,
>      <20261125113106.GM3898744@ragnatech.se>).
>   - Rewrote the commit message and added the Fixes tag per Niklas's review.
>   - No functional code change relative to v4 patch 1/3.
> 
> Testing:
>   Compile tested only (no Renesas R-Car Gen3 hardware): arm64
>   (aarch64-linux-gnu-gcc, CONFIG_ARCH_RENESAS=y, CONFIG_RCAR_GEN3_THERMAL=y,
>   W=1, 0 warnings) against 666539eecdf4.
> 
> AI assistance:
>   AI tools assisted with initial static analysis and commit/patch drafting;
>   the author manually reviewed the probe/remove paths, verified commit
>   c3131bd5586d, ran the arm64 compile check, and takes full responsibility
>   for the patch.
> 
>  drivers/thermal/renesas/rcar_gen3_thermal.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/thermal/renesas/rcar_gen3_thermal.c b/drivers/thermal/renesas/rcar_gen3_thermal.c
> index 9c64cbc2ee670..a96f02d4a8adf 100644
> --- a/drivers/thermal/renesas/rcar_gen3_thermal.c
> +++ b/drivers/thermal/renesas/rcar_gen3_thermal.c
> @@ -557,6 +557,10 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
>  	}
>  
>  	priv->num_tscs = i;
> +	if (!priv->num_tscs) {
> +		ret = -ENODEV;
> +		goto error_unregister;
> +	}
>  
>  	if (!rcar_gen3_thermal_read_fuses(priv))
>  		dev_info(dev, "No calibration values fused, fallback to driver values\n");
> @@ -588,11 +592,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
>  		dev_info(dev, "Sensor %u: Loaded\n", i);
>  	}
>  
> -	if (!priv->num_tscs) {
> -		ret = -ENODEV;
> -		goto error_unregister;
> -	}
> -
>  	return 0;
>  
>  error_unregister:
> -- 
> 2.34.1
> 

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2026-11-26 11:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 14:53 [PATCH] thermal: rcar_gen3: quiesce the interrupt source before releasing it Yaohan Li
2026-11-18  9:31 ` Niklas Söderlund
2026-11-19  2:29 ` [PATCH v2] thermal: rcar_gen3: release the IRQ handlers before the zones are freed Yaohan Li
2026-11-22 14:48   ` Niklas Söderlund
2026-11-23  2:21     ` Yaohan Li
2026-11-23  6:47       ` Niklas Söderlund
2026-11-24  2:22         ` Yaohan Li
2026-11-24  6:40           ` Niklas Söderlund
2026-11-24  9:51   ` [PATCH v3] thermal: rcar_gen3: register the interrupt handlers after the zones Yaohan Li
2026-11-24 13:15     ` Niklas Söderlund
2026-11-25  3:03     ` [PATCH v4 0/3] thermal: rcar_gen3: fix the interrupt handler lifetimes Yaohan Li
2026-11-25  3:03       ` [PATCH v4 1/3] thermal: rcar_gen3: check for sensors before reading the fuses Yaohan Li
2026-11-25  6:04         ` Niklas Söderlund
2026-11-26  1:36           ` [PATCH v5] " Yaohan Li
2026-11-26 11:58             ` Niklas Söderlund [this message]
2026-11-25  3:03       ` [PATCH v4 2/3] thermal: rcar_gen3: release the interrupt handlers from ->remove() Yaohan Li
2026-11-25  7:33         ` Niklas Söderlund
2026-11-25 11:18           ` zhang san
2026-11-25 11:31             ` Niklas Söderlund
2026-11-25  3:03       ` [PATCH v4 3/3] thermal: rcar_gen3: do not enable the interrupts before the zones exist Yaohan Li

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=20261126115806.GN3898744@ragnatech.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=daniel.lezcano@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=magnus.damm@gmail.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=shunsheng1218@gmail.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

all inboxes | Powered by JetHome®