summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorDenis Arefev <arefev@swemel.ru>2025-03-21 13:52:33 +0300
committerAlex Deucher <alexander.deucher@amd.com>2025-03-26 17:41:31 -0400
commit4e3d9508c056d7e0a56b58d5c81253e2a0d22b6c (patch)
tree1e0c4212b2c6d0ce95784411dc51b1975765978a /drivers/gpu
parent7d641c2b83275d3b0424127b2e0d2d0f7dd82aef (diff)
downloadlinux-4e3d9508c056d7e0a56b58d5c81253e2a0d22b6c.tar.gz
linux-4e3d9508c056d7e0a56b58d5c81253e2a0d22b6c.tar.bz2
linux-4e3d9508c056d7e0a56b58d5c81253e2a0d22b6c.zip
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: 031db09017da ("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
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c
index a3331ffb2daf..1b1c88590156 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c
@@ -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)) {