Skip to content

Commit

Permalink
IB/uverbs: Fix reference counting on error paths
Browse files Browse the repository at this point in the history
If an operation fails after incrementing an object's reference count,
then it should decrement the reference count on the error path.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Jack Morgenstein authored and Roland Dreier committed Jan 7, 2006
1 parent 4de144b commit b4ca1a3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/infiniband/core/uverbs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,

err_unreg:
ib_dereg_mr(mr);
atomic_dec(&pd->usecnt);

err_up:
up(&ib_uverbs_idr_mutex);
Expand Down Expand Up @@ -935,6 +936,11 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,

err_destroy:
ib_destroy_qp(qp);
atomic_dec(&pd->usecnt);
atomic_dec(&attr.send_cq->usecnt);
atomic_dec(&attr.recv_cq->usecnt);
if (attr.srq)
atomic_dec(&attr.srq->usecnt);

err_up:
up(&ib_uverbs_idr_mutex);
Expand Down Expand Up @@ -1729,6 +1735,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,

err_destroy:
ib_destroy_srq(srq);
atomic_dec(&pd->usecnt);

err_up:
up(&ib_uverbs_idr_mutex);
Expand Down

0 comments on commit b4ca1a3

Please sign in to comment.