diff options
author | Christian König <christian.koenig@amd.com> | 2015-06-23 17:07:03 +0200 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-06-29 11:21:49 -0400 |
commit | 9a5e8fb1c8372ea4b58a76bbb82cb97683bb204b (patch) | |
tree | af92dc30bcf8d7e8af94f71f6a5bc233ad1e033e /drivers/gpu | |
parent | b8682ac253bdab6c15678f926bdc028b2e5dc0d2 (diff) | |
download | linux-9a5e8fb1c8372ea4b58a76bbb82cb97683bb204b.tar.gz linux-9a5e8fb1c8372ea4b58a76bbb82cb97683bb204b.tar.bz2 linux-9a5e8fb1c8372ea4b58a76bbb82cb97683bb204b.zip |
drm/amdgpu: add chunk id validity check
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 7cd567b268fd..86b78c799176 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -181,8 +181,6 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) } p->chunks[i].chunk_id = user_chunk.chunk_id; p->chunks[i].length_dw = user_chunk.length_dw; - if (p->chunks[i].chunk_id == AMDGPU_CHUNK_ID_IB) - p->num_ibs++; size = p->chunks[i].length_dw; cdata = (void __user *)(unsigned long)user_chunk.chunk_data; @@ -199,7 +197,12 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) goto out; } - if (p->chunks[i].chunk_id == AMDGPU_CHUNK_ID_FENCE) { + switch (p->chunks[i].chunk_id) { + case AMDGPU_CHUNK_ID_IB: + p->num_ibs++; + break; + + case AMDGPU_CHUNK_ID_FENCE: size = sizeof(struct drm_amdgpu_cs_chunk_fence); if (p->chunks[i].length_dw * sizeof(uint32_t) >= size) { uint32_t handle; @@ -221,6 +224,11 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) r = -EINVAL; goto out; } + break; + + default: + r = -EINVAL; + goto out; } } |