[PATCH] drm/amdgpu: add check to avoid array bound issue
Zhou1, Tao
Tao.Zhou1 at amd.com
Thu Aug 8 07:18:57 UTC 2019
Reviewed-by: Tao Zhou <tao.zhou1 at amd.com>
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of
> Guchun Chen
> Sent: 2019年8月8日 14:59
> To: amd-gfx at lists.freedesktop.org; Zhang, Hawking
> <Hawking.Zhang at amd.com>; Li, Dennis <Dennis.Li at amd.com>; Pan, Xinhui
> <Xinhui.Pan at amd.com>; Zhou1, Tao <Tao.Zhou1 at amd.com>
> Cc: Chen, Guchun <Guchun.Chen at amd.com>
> Subject: [PATCH] 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.
>
> Change-Id: I556fc560b44215848ba3a95f757febdf3d0af422
> Signed-off-by: Guchun Chen <guchun.chen at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> index 3e46cce60553..59c77b01c88a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
> @@ -5960,6 +5960,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;
>
> --
> 2.17.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
More information about the amd-gfx
mailing list