Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: c52dcf49195d ("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

authored by

Denis Arefev and committed by
Alex Deucher
7c246a05 4b8c3c0d

+2 -2
+2 -2
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_thermal.c
··· 267 267 if (hwmgr->thermal_controller.fanInfo.bNoFan || 268 268 (hwmgr->thermal_controller.fanInfo. 269 269 ucTachometerPulsesPerRevolution == 0) || 270 - speed == 0 || 270 + (!speed || speed > UINT_MAX/8) || 271 271 (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || 272 272 (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) 273 - return 0; 273 + return -EINVAL; 274 274 275 275 if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 276 276 smu7_fan_ctrl_stop_smc_fan_control(hwmgr);