提交 b4ca1a3f 编写于 作者: J Jack Morgenstein 提交者: Roland Dreier

IB/uverbs: Fix reference counting on error paths

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: NJack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: NMichael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: NRoland Dreier <rolandd@cisco.com>
上级 4de144bf
...@@ -489,6 +489,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, ...@@ -489,6 +489,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
err_unreg: err_unreg:
ib_dereg_mr(mr); ib_dereg_mr(mr);
atomic_dec(&pd->usecnt);
err_up: err_up:
up(&ib_uverbs_idr_mutex); up(&ib_uverbs_idr_mutex);
...@@ -935,6 +936,11 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, ...@@ -935,6 +936,11 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
err_destroy: err_destroy:
ib_destroy_qp(qp); 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: err_up:
up(&ib_uverbs_idr_mutex); up(&ib_uverbs_idr_mutex);
...@@ -1729,6 +1735,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file, ...@@ -1729,6 +1735,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
err_destroy: err_destroy:
ib_destroy_srq(srq); ib_destroy_srq(srq);
atomic_dec(&pd->usecnt);
err_up: err_up:
up(&ib_uverbs_idr_mutex); up(&ib_uverbs_idr_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册