Skip to content

Commit 72cbaf8

Browse files
rafaeljwgregkh
authored andcommitted
thermal: gov_power_allocator: Add missing NULL pointer check
commit ac1f43c upstream. Commit 0dc2356 ("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(). 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: 0dc2356 ("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> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Link: https://patch.msgid.link/2761105.mvXUDI8C0e@rjwysocki.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3e8653e commit 72cbaf8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/thermal/gov_power_allocator.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,15 @@ static void allow_maximum_power(struct thermal_zone_device *tz)
582582
static int check_power_actors(struct thermal_zone_device *tz,
583583
struct power_allocator_params *params)
584584
{
585-
const struct thermal_trip_desc *td = trip_to_trip_desc(params->trip_max);
585+
const struct thermal_trip_desc *td;
586586
struct thermal_instance *instance;
587587
int ret = 0;
588588

589+
if (!params->trip_max)
590+
return 0;
591+
592+
td = trip_to_trip_desc(params->trip_max);
593+
589594
list_for_each_entry(instance, &td->thermal_instances, trip_node) {
590595
if (!cdev_is_power_actor(instance->cdev)) {
591596
dev_warn(&tz->device, "power_allocator: %s is not a power actor\n",

0 commit comments

Comments
 (0)