]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:06:40 +0000 (11:06 +0200)
[ Upstream commit 8944acd0f9db33e17f387fdc75d33bb473d7936f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c

index 78ac6dbe70d84e22c9e2497354df636416931752..854b2186025747a1d6246e7b27fe1c578bb07d72 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;