Skip to content

Commit 4e3d950

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: 031db09 ("drm/amd/powerplay/vega20: enable fan RPM and pwm settings V2") Signed-off-by: Denis Arefev <arefev@swemel.ru> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent 7d641c2 commit 4e3d950

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
191191
uint32_t tach_period, crystal_clock_freq;
192192
int result = 0;
193193

194-
if (!speed)
194+
if (!speed || speed > UINT_MAX/8)
195195
return -EINVAL;
196196

197197
if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) {

0 commit comments

Comments
 (0)