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: b64625a303de ("drm/amd/pm: correct the address of Arcturus fan related registers")
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
7d641c2b f23e9116

+3
+3
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
··· 1267 1267 uint32_t crystal_clock_freq = 2500; 1268 1268 uint32_t tach_period; 1269 1269 1270 + if (!speed || speed > UINT_MAX/8) 1271 + return -EINVAL; 1272 + 1270 1273 tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); 1271 1274 WREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT, 1272 1275 REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT),