]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/pm/swsmu/smu13/smu_v13_0: Prevent division by zero
authorDenis Arefev <arefev@swemel.ru>
Fri, 21 Mar 2025 10:52:31 +0000 (13:52 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:15 +0000 (07:44 +0200)
commit f23e9116ebb71b63fe9cec0dcac792aa9af30b0c 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: c05d1c401572 ("drm/amd/swsmu: add aldebaran smu13 ip support (v3)")
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/swsmu/smu13/smu_v13_0.c

index 7671a8b3c195a26cc10928d1a64a525778653197..7524427b044f34fb64faaa68419730b697ae65af 100644 (file)
@@ -1154,7 +1154,7 @@ int smu_v13_0_set_fan_speed_rpm(struct smu_context *smu,
        int ret;
        uint32_t tach_period, crystal_clock_freq;
 
-       if (!speed)
+       if (!speed || speed > UINT_MAX/8)
                return -EINVAL;
 
        ret = smu_v13_0_auto_fan_control(smu, 0);