From: Marek Olšák Date: Mon, 4 May 2015 22:56:45 +0000 (+0200) Subject: drm/amdgpu: remove unsafe context releasing X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=f11358daa93a8ae9fdee5cfe6ef7a0ed0027edee;p=linux-beck.git drm/amdgpu: remove unsafe context releasing If ctx was released between put and get, then "get" would crash. Signed-off-by: Marek Olšák Reviewed-by: Christian König Reviewed-by: Jammy Zhou --- 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 int amdgpu_ctx_free(struct amdgpu_device *adev, struct amdgpu_fpriv *fpriv, uint32_t id) { - int r; struct amdgpu_ctx *ctx; 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 ctx = idr_find(&mgr->ctx_handles, id); rcu_read_unlock(); if (ctx) { - /* if no task is pending on this context, free it */ - r = kref_put(&ctx->refcount, amdgpu_ctx_do_release); - if (r == 1) - return 0;//context is removed successfully - else { - /* context is still in using */ - kref_get(&ctx->refcount); - return -ERESTARTSYS; - } + kref_put(&ctx->refcount, amdgpu_ctx_do_release); + return 0; } return -EINVAL; }