]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/pm/powerplay/hwmgr/vega20_thermal: Prevent division by zero
authorDenis Arefev <arefev@swemel.ru>
Fri, 21 Mar 2025 10:52:33 +0000 (13:52 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:41:03 +0000 (07:41 +0200)
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: 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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_thermal.c

index 364162ddaa9c672d023531166f7f8d3683e6d1b8..87b7baa9492bf395f3f77978bde1091fd878eec7 100644 (file)
@@ -189,7 +189,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)) {