Skip to content

Commit

Permalink
thermal: gov_power_allocator: Return early in manage if trip_max is NULL
Browse files Browse the repository at this point in the history
Commit da78193 ("thermal: gov_power_allocator: Allow binding
without trip points") allowed the governor to bind even when trip_max
is NULL. This allows a NULL pointer dereference to happen in the manage
callback.

Add an early return to prevent it, since the governor is expected to not do
anything in this case.

Fixes: da78193 ("thermal: gov_power_allocator: Allow binding without trip points")
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Link: https://patch.msgid.link/20240702-power-allocator-null-trip-max-v1-1-47a60dc55414@collabora.com
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Nícolas F. R. A. Prado authored and Rafael J. Wysocki committed Jul 4, 2024
1 parent 22a40d1 commit aaa18ff
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/thermal/gov_power_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,9 @@ static void power_allocator_manage(struct thermal_zone_device *tz)
return;
}

if (!params->trip_max)
return;

allocate_power(tz, params->trip_max->temperature);
params->update_cdevs = true;
}
Expand Down

0 comments on commit aaa18ff

Please sign in to comment.