diff options
author | Guchun Chen <guchun.chen@amd.com> | 2019-08-08 14:54:41 +0800 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-08-12 12:47:48 -0500 |
commit | a2b459947b1e8e9b8d8cb13640bc019ee932ea30 (patch) | |
tree | ef7d9ea6dd29511703a83744f7956fd82fcdab6e | |
parent | 3c0b547da0d7f9011c87f081ef3cd743b367b088 (diff) | |
download | linux-a2b459947b1e8e9b8d8cb13640bc019ee932ea30.tar.bz2 |
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 <guchun.chen@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 |
1 files changed, 3 insertions, 0 deletions
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; |