From: "Zhang, Rui" <rui.zhang@intel.com>
To: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference
Date: Wed, 29 Mar 2023 11:24:33 +0000 [thread overview]
Message-ID: <794b4b0eb6a0181b5e01f17e720a56e5ffaaf2e9.camel@intel.com> (raw)
In-Reply-To: <08aee7fe-eddc-7841-2539-16ae43fd8d66@linaro.org>
On Wed, 2023-03-29 at 11:57 +0200, Daniel Lezcano wrote:
> On 29/03/2023 11:00, Zhang Rui wrote:
> > When the hwmon device node of a thermal zone device is not found,
> > using hwmon->device causes a kernel NULL pointer dereference.
> >
> > Reported-by: Preble Adam C <adam.c.preble@intel.com>
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> > Fixes: dec07d399cc8 ("thermal: Don't use 'device' internal thermal
> > zone structure field")
> > dec07d399cc8 is a commit in the linux-next branch of linux-pm repo.
> > I'm not sure if the Fix tag applies to such commit or not.
>
> Actually it reverts the work done to encapsulate the thermal zone
> device
> structure.
>
> > ---
> > drivers/thermal/thermal_hwmon.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/thermal_hwmon.c
> > b/drivers/thermal/thermal_hwmon.c
> > index c59db17dddd6..261743f461be 100644
> > --- a/drivers/thermal/thermal_hwmon.c
> > +++ b/drivers/thermal/thermal_hwmon.c
> > @@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct
> > thermal_zone_device *tz)
> > hwmon = thermal_hwmon_lookup_by_type(tz);
> > if (unlikely(!hwmon)) {
> > /* Should never happen... */
> > - dev_dbg(hwmon->device, "hwmon device lookup
> > failed!\n");
> > + dev_dbg(&tz->device, "hwmon device lookup failed!\n");
>
> As it 'Should never happen', I would replace that by:
>
> if (WARN_ON(!hwmon))
> /* Should never happen... */
> return;
Actually, the comment is wrong.
For thermal zones with tzp->no_hwmon set, this is always true.
We should add an extra check for that.
thanks,
rui
next prev parent reply other threads:[~2023-03-29 11:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 9:00 [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference Zhang Rui
2023-03-29 9:57 ` Daniel Lezcano
2023-03-29 10:55 ` Rafael J. Wysocki
2023-03-29 11:24 ` Zhang, Rui [this message]
2023-03-29 12:01 ` Rafael J. Wysocki
2023-03-29 12:06 ` Rafael J. Wysocki
2023-03-29 12:33 ` Zhang, Rui
2023-03-29 13:50 ` Rafael J. Wysocki
2023-03-29 14:16 ` Daniel Lezcano
2023-03-29 14:38 ` Rafael J. Wysocki
2023-03-29 15:59 ` Daniel Lezcano
2023-03-29 16:03 ` Rafael J. Wysocki
2023-03-29 16:18 ` Daniel Lezcano
2023-03-29 17:43 ` Rafael J. Wysocki
2023-03-29 18:39 ` Daniel Lezcano
2023-03-29 16:00 ` Daniel Lezcano
2023-03-29 17:05 ` Rafael J. Wysocki
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=794b4b0eb6a0181b5e01f17e720a56e5ffaaf2e9.camel@intel.com \
--to=rui.zhang@intel.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.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