]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amd/pm/smu11: Prevent division by zero
authorDenis Arefev <arefev@swemel.ru>
Thu, 20 Mar 2025 09:35:02 +0000 (12:35 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 9 Apr 2025 14:53:11 +0000 (10:53 -0400)
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: 1e866f1fe528 ("drm/amd/pm: Prevent divide by zero")
Signed-off-by: Denis Arefev <arefev@swemel.ru>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit da7dc714a8f8e1c9fc33c57cd63583779a3bef71)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c

index 78391d8f35a9cbb52ea02ecc5ec99222d5f9d332..25fabf336a6401dff12e0268362421b452647eb3 100644 (file)
@@ -1204,7 +1204,7 @@ int smu_v11_0_set_fan_speed_rpm(struct smu_context *smu,
        uint32_t crystal_clock_freq = 2500;
        uint32_t tach_period;
 
-       if (speed == 0)
+       if (!speed || speed > UINT_MAX/8)
                return -EINVAL;
        /*
         * To prevent from possible overheat, some ASICs may have requirement