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, 25 Apr 2025 08:45:53 +0000 (10:45 +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 c0adfa46ac78968c5896142ac521aa6deb2f87a7..8504692be47f17e01a8556cfb06fbe096317c70e 100644 (file)
@@ -1227,7 +1227,7 @@ int smu_v13_0_set_fan_speed_rpm(struct smu_context *smu,
        uint32_t tach_period;
        int ret;
 
-       if (!speed)
+       if (!speed || speed > UINT_MAX/8)
                return -EINVAL;
 
        ret = smu_v13_0_auto_fan_control(smu, 0);