]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: gov_power_allocator: Return early in manage if trip_max is NULL
authorNícolas F. R. A. Prado <nfraprado@collabora.com>
Tue, 2 Jul 2024 21:24:56 +0000 (17:24 -0400)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 4 Jul 2024 11:35:50 +0000 (13:35 +0200)
Commit da781936e7c3 ("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: da781936e7c3 ("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>
drivers/thermal/gov_power_allocator.c

index 45f04a25255a33d06afef900c78aac50e6fd0f8f..1b2345a697c5a0338e7f62484356fcb23737ea03 100644 (file)
@@ -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;
 }