[PATCH 1/2] drm/amdgpu: fix ucode out-of-bounds read warning
Alex Deucher
alexdeucher at gmail.com
Mon May 6 15:10:51 UTC 2024
On Mon, May 6, 2024 at 5:26 AM Tim Huang <Tim.Huang at amd.com> wrote:
>
> Clear warning that read ucode[] may out-of-bounds.
>
> Signed-off-by: Tim Huang <Tim.Huang at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> index b8280be6225d..c3d89088123d 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;
> --
> 2.39.2
>
More information about the amd-gfx
mailing list