From: Guchun Chen Date: Thu, 8 Aug 2019 06:54:41 +0000 (+0800) Subject: drm/amdgpu: add check to avoid array bound issue X-Git-Tag: Ubuntu-5.13.0-19.19~7656^2~7^2~252 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=a2b459947b1e8e9b8d8cb13640bc019ee932ea30;p=mirror_ubuntu-jammy-kernel.git drm/amdgpu: add check to avoid array bound issue Sub_block_index can be passed from user level, so add one check before accessing the array first to prevent array index out of bound problem. Signed-off-by: Guchun Chen Reviewed-by: Tao Zhou Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 52a6fd12e266..24ff32103bca 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c @@ -5978,6 +5978,9 @@ static int gfx_v9_0_ras_error_inject(struct amdgpu_device *adev, if (adev->asic_type != CHIP_VEGA20) return -EINVAL; + if (info->head.sub_block_index >= ARRAY_SIZE(ras_gfx_subblocks)) + return -EINVAL; + if (!ras_gfx_subblocks[info->head.sub_block_index].name) return -EPERM;