Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by

Jack Morgenstein and committed by
Roland Dreier
b4ca1a3f 4de144bf

+7
+7
drivers/infiniband/core/uverbs_cmd.c
··· 489 489 490 490 err_unreg: 491 491 ib_dereg_mr(mr); 492 + atomic_dec(&pd->usecnt); 492 493 493 494 err_up: 494 495 up(&ib_uverbs_idr_mutex); ··· 936 935 937 936 err_destroy: 938 937 ib_destroy_qp(qp); 938 + atomic_dec(&pd->usecnt); 939 + atomic_dec(&attr.send_cq->usecnt); 940 + atomic_dec(&attr.recv_cq->usecnt); 941 + if (attr.srq) 942 + atomic_dec(&attr.srq->usecnt); 939 943 940 944 err_up: 941 945 up(&ib_uverbs_idr_mutex); ··· 1735 1729 1736 1730 err_destroy: 1737 1731 ib_destroy_srq(srq); 1732 + atomic_dec(&pd->usecnt); 1738 1733 1739 1734 err_up: 1740 1735 up(&ib_uverbs_idr_mutex);