aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-07-06 13:42:10 -0400
committerAlex Deucher <alexander.deucher@amd.com>2015-07-16 12:39:38 -0400
commit76a1ea618f01b2bf5a325832d1c273c039c4ea81 (patch)
treefab6c23af9e4fcefb486767e5ca5e50d3ed67fb6 /drivers/gpu/drm/amd
parent12f1384da650bdb835fff63e66fe815ea882fc0e (diff)
drm/amdgpu: validate the context id in the dependencies
Just to make sure userspace don't send nonsense to the kernel. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index d63135bf29c0..469b6f2364bc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -669,6 +669,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
669static int amdgpu_cs_dependencies(struct amdgpu_device *adev, 669static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
670 struct amdgpu_cs_parser *p) 670 struct amdgpu_cs_parser *p)
671{ 671{
672 struct amdgpu_fpriv *fpriv = p->filp->driver_priv;
672 struct amdgpu_ib *ib; 673 struct amdgpu_ib *ib;
673 int i, j, r; 674 int i, j, r;
674 675
@@ -694,6 +695,7 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
694 for (j = 0; j < num_deps; ++j) { 695 for (j = 0; j < num_deps; ++j) {
695 struct amdgpu_fence *fence; 696 struct amdgpu_fence *fence;
696 struct amdgpu_ring *ring; 697 struct amdgpu_ring *ring;
698 struct amdgpu_ctx *ctx;
697 699
698 r = amdgpu_cs_get_ring(adev, deps[j].ip_type, 700 r = amdgpu_cs_get_ring(adev, deps[j].ip_type,
699 deps[j].ip_instance, 701 deps[j].ip_instance,
@@ -701,14 +703,21 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
701 if (r) 703 if (r)
702 return r; 704 return r;
703 705
706 ctx = amdgpu_ctx_get(fpriv, deps[j].ctx_id);
707 if (ctx == NULL)
708 return -EINVAL;
709
704 r = amdgpu_fence_recreate(ring, p->filp, 710 r = amdgpu_fence_recreate(ring, p->filp,
705 deps[j].handle, 711 deps[j].handle,
706 &fence); 712 &fence);
707 if (r) 713 if (r) {
714 amdgpu_ctx_put(ctx);
708 return r; 715 return r;
716 }
709 717
710 amdgpu_sync_fence(&ib->sync, fence); 718 amdgpu_sync_fence(&ib->sync, fence);
711 amdgpu_fence_unref(&fence); 719 amdgpu_fence_unref(&fence);
720 amdgpu_ctx_put(ctx);
712 } 721 }
713 } 722 }
714 723