drm/amdgpu: fix ucode out-of-bounds read warning

[ Upstream commit 8944acd0f9db33e17f387fdc75d33bb473d7936f ]

Clear warning that read ucode[] may out-of-bounds.

This fixes CVE-2024-46723

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>
Signed-off-by: Huang Cun <cunhuang@tencent.com>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
This commit is contained in:
Tim Huang 2024-05-06 16:21:00 +08:00 committed by Jianping Liu
parent ea2553a506
commit 7329d8df96
1 changed files with 3 additions and 0 deletions

View File

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