Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: gov_power_allocator: Add missing NULL pointer check

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().

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>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/2761105.mvXUDI8C0e@rjwysocki.net

+6 -1
+6 -1
drivers/thermal/gov_power_allocator.c
··· 588 588 static int check_power_actors(struct thermal_zone_device *tz, 589 589 struct power_allocator_params *params) 590 590 { 591 - const struct thermal_trip_desc *td = trip_to_trip_desc(params->trip_max); 591 + const struct thermal_trip_desc *td; 592 592 struct thermal_instance *instance; 593 593 int ret = 0; 594 + 595 + if (!params->trip_max) 596 + return 0; 597 + 598 + td = trip_to_trip_desc(params->trip_max); 594 599 595 600 list_for_each_entry(instance, &td->thermal_instances, trip_node) { 596 601 if (!cdev_is_power_actor(instance->cdev)) {