Skip to content

Commit 7c246a0

Browse files
Denis Arefevalexdeucher
authored andcommitted
drm/amd/pm: Prevent division by zero
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 <arefev@swemel.ru> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent 4b8c3c0 commit 7c246a0

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)