From: Lukasz Luba <lukasz.luba@arm.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Sasha Levin <sashal@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Linus Torvalds <torvalds@linuxfoundation.org>
Subject: Re: [PATCH v1] thermal: gov_power_allocator: Add missing NULL pointer check
Date: Tue, 26 Nov 2024 09:36:11 +0000 [thread overview]
Message-ID: <11359a2f-6573-4b07-b333-e20683d690fa@arm.com> (raw)
In-Reply-To: <2761105.mvXUDI8C0e@rjwysocki.net>
On 11/25/24 11:24, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Commit 0dc23567c206 ("thermal: core: Move lists of thermal instances
> to trip descriptors") overlooked the case in which the Power Allocator
> governor attempts to bind to a tripless thermal zone and params->trip_max
> is NULL in check_power_actors().
That corner case sneaked in...
>
> No power actors can be found in that case, so check_power_actors() needs
> to be made return 0 then to restore its previous behavior.
>
> Fixes: 0dc23567c206 ("thermal: core: Move lists of thermal instances to trip descriptors")
> Closes: https://lore.kernel.org/linux-pm/Z0NeGF4ryCe_b5rr@sashalap/
> Reported-by: Sasha Levin <sashal@kernel.org>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/thermal/gov_power_allocator.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> Index: linux-pm/drivers/thermal/gov_power_allocator.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/gov_power_allocator.c
> +++ linux-pm/drivers/thermal/gov_power_allocator.c
> @@ -588,10 +588,15 @@ static void allow_maximum_power(struct t
> static int check_power_actors(struct thermal_zone_device *tz,
> struct power_allocator_params *params)
> {
> - const struct thermal_trip_desc *td = trip_to_trip_desc(params->trip_max);
> + const struct thermal_trip_desc *td;
> struct thermal_instance *instance;
> int ret = 0;
>
> + if (!params->trip_max)
> + return 0;
Yes, 0 is the right thing to return here, since we might get later some
trip points.
> +
> + td = trip_to_trip_desc(params->trip_max);
> +
> list_for_each_entry(instance, &td->thermal_instances, trip_node) {
> if (!cdev_is_power_actor(instance->cdev)) {
> dev_warn(&tz->device, "power_allocator: %s is not a power actor\n",
>
>
>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
prev parent reply other threads:[~2024-11-26 9:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 11:24 [PATCH v1] thermal: gov_power_allocator: Add missing NULL pointer check Rafael J. Wysocki
2024-11-26 9:36 ` Lukasz Luba [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=11359a2f-6573-4b07-b333-e20683d690fa@arm.com \
--to=lukasz.luba@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=sashal@kernel.org \
--cc=torvalds@linuxfoundation.org \
/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