From: Colin Ian King <colin.i.king@gmail.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked
Date: Wed, 30 Jul 2025 14:54:41 +0100 [thread overview]
Message-ID: <20250730135441.2078022-1-colin.i.king@gmail.com> (raw)
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
next reply other threads:[~2025-07-30 13:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 13:54 Colin Ian King [this message]
2025-07-30 17:43 ` [PATCH][next] thermal: tegra: Fix dereference of pointer tz before it is null checked Markus Elfring
2025-07-31 8:03 ` Colin King (gmail)
2025-08-01 17:22 ` Daniel Lezcano
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=20250730135441.2078022-1-colin.i.king@gmail.com \
--to=colin.i.king@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=jonathanh@nvidia.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=thierry.reding@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;
as well as URLs for NNTP newsgroup(s).