* [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked
@ 2025-07-30 13:54 Colin Ian King
2025-07-30 17:43 ` Markus Elfring
2025-08-01 17:22 ` Daniel Lezcano
0 siblings, 2 replies; 4+ messages in thread
From: Colin Ian King @ 2025-07-30 13:54 UTC (permalink / raw)
To: Rafael J . Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
Thierry Reding, Jonathan Hunter, linux-pm, linux-tegra
Cc: kernel-janitors, linux-kernel
Currently pointer tz is dereferenced before it is being null checked
leading to a potential null pointer deferernce issue. Fix this by
only defererencing it once it has been null checked.
Fixes: 6fc2e1a5f98f ("thermal/drivers/tegra: Switch to new of API")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/thermal/tegra/soctherm.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index 53a5c649f4b1..53fa6099b67f 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c
@@ -585,14 +585,19 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)
static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz,
const struct thermal_trip *trip, int temp)
{
- struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);
- struct tegra_soctherm *ts = zone->ts;
- const struct tegra_tsensor_group *sg = zone->sg;
- struct device *dev = zone->dev;
+ struct tegra_thermctl_zone *zone;
+ struct tegra_soctherm *ts;
+ const struct tegra_tsensor_group *sg;
+ struct device *dev;
if (!tz)
return -EINVAL;
+ zone = thermal_zone_device_priv(tz);
+ ts = zone->ts;
+ sg = zone->sg;
+ dev = zone->dev;
+
if (trip->type == THERMAL_TRIP_CRITICAL) {
/*
* If thermtrips property is set in DT,
--
2.50.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked
2025-07-30 13:54 [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked Colin Ian King
@ 2025-07-30 17:43 ` Markus Elfring
2025-07-31 8:03 ` Colin King (gmail)
2025-08-01 17:22 ` Daniel Lezcano
1 sibling, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2025-07-30 17:43 UTC (permalink / raw)
To: Colin Ian King, linux-pm, linux-tegra, Daniel Lezcano,
Jonathan Hunter, Lukasz Luba, Rafael J. Wysocki, Thierry Reding,
Zhang Rui
Cc: kernel-janitors, linux-kernel
> Currently pointer tz is dereferenced before it is being null checked
> leading to a potential null pointer deferernce issue. Fix this by
…
dereference?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked
2025-07-30 17:43 ` Markus Elfring
@ 2025-07-31 8:03 ` Colin King (gmail)
0 siblings, 0 replies; 4+ messages in thread
From: Colin King (gmail) @ 2025-07-31 8:03 UTC (permalink / raw)
To: Markus Elfring, linux-pm, linux-tegra, Daniel Lezcano,
Jonathan Hunter, Lukasz Luba, Rafael J. Wysocki, Thierry Reding,
Zhang Rui
Cc: kernel-janitors, linux-kernel
[-- Attachment #1.1.1: Type: text/plain, Size: 342 bytes --]
Shall I send a V2, or can this be fixed up when it's applied?
On 30/07/2025 18:43, Markus Elfring wrote:
>> Currently pointer tz is dereferenced before it is being null checked
>> leading to a potential null pointer deferernce issue. Fix this by
> …
> dereference?
>
> Regards,
> Markus
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 4901 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked
2025-07-30 13:54 [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked Colin Ian King
2025-07-30 17:43 ` Markus Elfring
@ 2025-08-01 17:22 ` Daniel Lezcano
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2025-08-01 17:22 UTC (permalink / raw)
To: Colin Ian King, Rafael J . Wysocki, Zhang Rui, Lukasz Luba,
Thierry Reding, Jonathan Hunter, linux-pm, linux-tegra
Cc: kernel-janitors, linux-kernel
On 30/07/2025 15:54, Colin Ian King wrote:
> Currently pointer tz is dereferenced before it is being null checked
> leading to a potential null pointer deferernce issue. Fix this by
> only defererencing it once it has been null checked.
Actually the callback should assume tz is never NULL because the caller
does:
ret = tz->ops.set_trip_temp(tz, trip, temp);
So removing the NULL pointer check is safe here.
> Fixes: 6fc2e1a5f98f ("thermal/drivers/tegra: Switch to new of API")
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/thermal/tegra/soctherm.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
> index 53a5c649f4b1..53fa6099b67f 100644
> --- a/drivers/thermal/tegra/soctherm.c
> +++ b/drivers/thermal/tegra/soctherm.c
> @@ -585,14 +585,19 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)
> static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz,
> const struct thermal_trip *trip, int temp)
> {
> - struct tegra_thermctl_zone *zone = thermal_zone_device_priv(tz);
> - struct tegra_soctherm *ts = zone->ts;
> - const struct tegra_tsensor_group *sg = zone->sg;
> - struct device *dev = zone->dev;
> + struct tegra_thermctl_zone *zone;
> + struct tegra_soctherm *ts;
> + const struct tegra_tsensor_group *sg;
> + struct device *dev;
>
> if (!tz)
> return -EINVAL;
>
> + zone = thermal_zone_device_priv(tz);
> + ts = zone->ts;
> + sg = zone->sg;
> + dev = zone->dev;
> +
> if (trip->type == THERMAL_TRIP_CRITICAL) {
> /*
> * If thermtrips property is set in DT,
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-01 17:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30 13:54 [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked Colin Ian King
2025-07-30 17:43 ` Markus Elfring
2025-07-31 8:03 ` Colin King (gmail)
2025-08-01 17:22 ` Daniel Lezcano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).