Skip to content

Commit

Permalink
drm/amd/pm/powerplay/hwmgr/vega20_thermal: Prevent division by zero
Browse files Browse the repository at this point in the history
commit 4e3d950 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 <arefev@swemel.ru>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Denis Arefev authored and Greg Kroah-Hartman committed Apr 25, 2025
1 parent fb803d4 commit 42f7b5d
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 42f7b5d

Please sign in to comment.