Skip to content

Commit

Permalink
IB/uverbs: Fix unbalanced unlock on error path for rdma_explicit_destroy
Browse files Browse the repository at this point in the history
If remove_commit fails then the lock is left locked while the uobj still
exists. Eventually the kernel will deadlock.

lockdep detects this and says:

 test/4221 is leaving the kernel with locks still held!
 1 lock held by test/4221:
  #0:  (&ucontext->cleanup_rwsem){.+.+}, at: [<000000001e5c7523>] rdma_explicit_destroy+0x37/0x120 [ib_uverbs]

Fixes: 4da70da ("IB/core: Explicitly destroy an object while keeping uobject")
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
jgunthorpe committed Feb 15, 2018
1 parent 104f268 commit ec6f840
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/infiniband/core/rdma_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,13 @@ int rdma_explicit_destroy(struct ib_uobject *uobject)
ret = uobject->type->type_class->remove_commit(uobject,
RDMA_REMOVE_DESTROY);
if (ret)
return ret;
goto out;

uobject->type = &null_obj_type;

out:
up_read(&ucontext->cleanup_rwsem);
return 0;
return ret;
}

static void alloc_commit_idr_uobject(struct ib_uobject *uobj)
Expand Down

0 comments on commit ec6f840

Please sign in to comment.