From: Tim Huang Date: Mon, 6 May 2024 08:21:00 +0000 (+0800) Subject: drm/amdgpu: fix ucode out-of-bounds read warning X-Git-Tag: v6.11-rc1~141^2~25^2~284 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8944acd0f9db33e17f387fdc75d33bb473d7936f;p=thirdparty%2Fkernel%2Flinux.git drm/amdgpu: fix ucode out-of-bounds read warning Clear warning that read ucode[] may out-of-bounds. Signed-off-by: Tim Huang Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index b8280be6225d9..c3d89088123db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c @@ -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;