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
4b8c3c0d 4e3d9508

+2 -2
+2 -2
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c
··· 307 307 int result = 0; 308 308 309 309 if (hwmgr->thermal_controller.fanInfo.bNoFan || 310 - speed == 0 || 310 + (!speed || speed > UINT_MAX/8) || 311 311 (speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) || 312 312 (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)) 313 - return -1; 313 + return -EINVAL; 314 314 315 315 if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) 316 316 result = vega10_fan_ctrl_stop_smc_fan_control(hwmgr);