Skip to content

Commit 826068b

Browse files
Denis Arefevvijay-suman
authored andcommitted
drm/amd/pm/powerplay/hwmgr/vega20_thermal: Prevent division by zero
commit 4e3d9508c056d7e0a56b58d5c81253e2a0d22b6c 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: 031db09 ("drm/amd/powerplay/vega20: enable fan RPM and pwm settings V2") 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 80814924260cea431a8fc6137d11cc8cb331a10c) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 41a33b1 commit 826068b

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)