Skip to content

Commit c149569

Browse files
Denis Arefevvijay-suman
authored andcommitted
drm/amd/pm/powerplay: Prevent division by zero
commit 4b8c3c0d17c07f301011e2908fecd2ebdcfe3d1c upstream. The user can set any speed value. If speed is greater than UINT_MAX/8, division by zero is possible. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: c52dcf4 ("drm/amd/pp: Avoid divide-by-zero in fan_ctrl_set_fan_speed_rpm") Signed-off-by: Denis Arefev <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 0c02fcbe4a1393a3c02da6ae35e72493cfdb2155) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 98ad72b commit c149569

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ int vega10_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
307307
int result = 0;
308308

309309
if (hwmgr->thermal_controller.fanInfo.bNoFan ||
310-
speed == 0 ||
310+
(!speed || speed > UINT_MAX/8) ||
311311
(speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) ||
312312
(speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM))
313-
return -1;
313+
return -EINVAL;
314314

315315
if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl))
316316
result = vega10_fan_ctrl_stop_smc_fan_control(hwmgr);

0 commit comments

Comments
 (0)