Skip to content

Commit 7d641c2

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: b64625a ("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
1 parent f23e911 commit 7d641c2

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
@@ -1267,6 +1267,9 @@ static int arcturus_set_fan_speed_rpm(struct smu_context *smu,
12671267
uint32_t crystal_clock_freq = 2500;
12681268
uint32_t tach_period;
12691269

1270+
if (!speed || speed > UINT_MAX/8)
1271+
return -EINVAL;
1272+
12701273
tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed);
12711274
WREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT,
12721275
REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL_ARCT),

0 commit comments

Comments
 (0)