Skip to content

Commit ac4931e

Browse files
Denis Arefevvijay-suman
authored andcommitted
drm/amd/pm/powerplay/hwmgr/smu7_thermal: Prevent division by zero
commit 7c246a05df51c52fe0852ce56ba10c41e6ed1f39 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 be0fffc4152aac4f0291ed2d793f3cfee788449d) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent c149569 commit ac4931e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
267267
if (hwmgr->thermal_controller.fanInfo.bNoFan ||
268268
(hwmgr->thermal_controller.fanInfo.
269269
ucTachometerPulsesPerRevolution == 0) ||
270-
speed == 0 ||
270+
(!speed || speed > UINT_MAX/8) ||
271271
(speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) ||
272272
(speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM))
273-
return 0;
273+
return -EINVAL;
274274

275275
if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl))
276276
smu7_fan_ctrl_stop_smc_fan_control(hwmgr);

0 commit comments

Comments
 (0)