Skip to content

Commit 98ad72b

Browse files
Denis Arefevvijay-suman
authored andcommitted
drm/amd/pm: Prevent division by zero
commit 7d641c2b83275d3b0424127b2e0d2d0f7dd82aef 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: b64625a ("drm/amd/pm: correct the address of Arcturus fan related registers") 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 b7c41df4913789ebfe73cc1e17c6401d4c5eab69) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 408cb2a commit 98ad72b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,9 @@ static int arcturus_set_fan_speed_rpm(struct smu_context *smu,
12781278
uint32_t crystal_clock_freq = 2500;
12791279
uint32_t tach_period;
12801280

1281+
if (!speed || speed > UINT_MAX/8)
1282+
return -EINVAL;
1283+
12811284
tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
12821285
WREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT,
12831286
REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT),

0 commit comments

Comments
 (0)