]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: fix ucode out-of-bounds read warning
authorTim Huang <Tim.Huang@amd.com>
Mon, 6 May 2024 08:21:00 +0000 (16:21 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 8 May 2024 19:17:07 +0000 (15:17 -0400)
Clear warning that read ucode[] may out-of-bounds.

Signed-off-by: Tim Huang <Tim.Huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c

index b8280be6225d9ff7ec498b7d0b7787724894ed6b..c3d89088123dbd2d94aa161115868ed60d22a5af 100644 (file)
@@ -213,6 +213,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
                struct amdgpu_firmware_info *ucode;
 
                id = fw_type_convert(cgs_device, type);
+               if (id >= AMDGPU_UCODE_ID_MAXIMUM)
+                       return -EINVAL;
+
                ucode = &adev->firmware.ucode[id];
                if (ucode->fw == NULL)
                        return -EINVAL;