diff options
author | Marek Olšák <marek.olsak@amd.com> | 2015-05-04 18:56:45 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-06-03 21:03:27 -0400 |
commit | f11358daa93a8ae9fdee5cfe6ef7a0ed0027edee (patch) | |
tree | 7ae6c7cf6be383628f28effe66698dd4106b4beb | |
parent | a961ea7349d08d5962b6a619f2c2cca670da41ed (diff) |
drm/amdgpu: remove unsafe context releasing
If ctx was released between put and get, then "get" would crash.
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 235010a83f8f..ffb13a66e288 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | |||
@@ -69,7 +69,6 @@ int amdgpu_ctx_alloc(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uin | |||
69 | 69 | ||
70 | int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint32_t id) | 70 | int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint32_t id) |
71 | { | 71 | { |
72 | int r; | ||
73 | struct amdgpu_ctx *ctx; | 72 | struct amdgpu_ctx *ctx; |
74 | struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr; | 73 | struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr; |
75 | 74 | ||
@@ -77,15 +76,8 @@ int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint | |||
77 | ctx = idr_find(&mgr->ctx_handles, id); | 76 | ctx = idr_find(&mgr->ctx_handles, id); |
78 | rcu_read_unlock(); | 77 | rcu_read_unlock(); |
79 | if (ctx) { | 78 | if (ctx) { |
80 | /* if no task is pending on this context, free it */ | 79 | kref_put(&ctx->refcount, amdgpu_ctx_do_release); |
81 | r = kref_put(&ctx->refcount, amdgpu_ctx_do_release); | 80 | return 0; |
82 | if (r == 1) | ||
83 | return 0;//context is removed successfully | ||
84 | else { | ||
85 | /* context is still in using */ | ||
86 | kref_get(&ctx->refcount); | ||
87 | return -ERESTARTSYS; | ||
88 | } | ||
89 | } | 81 | } |
90 | return -EINVAL; | 82 | return -EINVAL; |
91 | } | 83 | } |