Skip to content

Commit

Permalink
drm/amd/pm: Prevent division by zero
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Denis Arefev authored and Alex Deucher committed Mar 26, 2025
1 parent 7d641c2 commit 4e3d950
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
uint32_t tach_period, crystal_clock_freq;
int result = 0;

if (!speed)
if (!speed || speed > UINT_MAX/8)
return -EINVAL;

if (PP_CAP(PHM_PlatformCaps_MicrocodeFanControl)) {
Expand Down

0 comments on commit 4e3d950

Please sign in to comment.