IB/uverbs: Fix reference counting on error paths
authorJack Morgenstein <jackm@mellanox.co.il>
Sat, 7 Jan 2006 00:21:19 +0000 (16:21 -0800)
committerRoland Dreier <rolandd@cisco.com>
Sat, 7 Jan 2006 00:21:19 +0000 (16:21 -0800)
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>
drivers/infiniband/core/uverbs_cmd.c

index a57d021d435ae2d4f0a694c134d643d2836582c7..6985a57fa6ae2176509ad97e7e9b843a0a56a976 100644 (file)
@@ -489,6 +489,7 @@ err_idr:
 
 err_unreg:
        ib_dereg_mr(mr);
+       atomic_dec(&pd->usecnt);
 
 err_up:
        up(&ib_uverbs_idr_mutex);
@@ -935,6 +936,11 @@ err_idr:
 
 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);
@@ -1729,6 +1735,7 @@ err_idr:
 
 err_destroy:
        ib_destroy_srq(srq);
+       atomic_dec(&pd->usecnt);
 
 err_up:
        up(&ib_uverbs_idr_mutex);