Commit f11358da authored by Marek Olšák's avatar Marek Olšák Committed by Alex Deucher

drm/amdgpu: remove unsafe context releasing

If ctx was released between put and get, then "get" would crash.
Signed-off-by: default avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarJammy Zhou <Jammy.Zhou@amd.com>
parent a961ea73
...@@ -69,7 +69,6 @@ int amdgpu_ctx_alloc(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uin ...@@ -69,7 +69,6 @@ int amdgpu_ctx_alloc(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uin
int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint32_t id) int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint32_t id)
{ {
int r;
struct amdgpu_ctx *ctx; struct amdgpu_ctx *ctx;
struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr; struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr;
...@@ -77,15 +76,8 @@ int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint ...@@ -77,15 +76,8 @@ int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint
ctx = idr_find(&mgr->ctx_handles, id); ctx = idr_find(&mgr->ctx_handles, id);
rcu_read_unlock(); rcu_read_unlock();
if (ctx) { if (ctx) {
/* if no task is pending on this context, free it */ kref_put(&ctx->refcount, amdgpu_ctx_do_release);
r = kref_put(&ctx->refcount, amdgpu_ctx_do_release); return 0;
if (r == 1)
return 0;//context is removed successfully
else {
/* context is still in using */
kref_get(&ctx->refcount);
return -ERESTARTSYS;
}
} }
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment