RDMA/ucma: Fix refcount 0 incr in ucma_get_ctx()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 18 Aug 2020 12:05:13 +0000 (15:05 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 27 Aug 2020 11:38:13 +0000 (08:38 -0300)
commitca2968c1efcbeb547906cf6211874ec881beafec
treef5d7b5f93d3d2270117006ddb69d56e79a7258a2
parent7c4b1ab9f16732fb921b3f11cd127fa65f26ad5c
RDMA/ucma: Fix refcount 0 incr in ucma_get_ctx()

Both ucma_destroy_id() and ucma_close_id() (triggered from an event via a
wq) can drive the refcount to zero. ucma_get_ctx() was wrongly assuming
that the refcount can only go to zero from ucma_destroy_id() which also
removes it from the xarray.

Use refcount_inc_not_zero() instead.

Link: https://lore.kernel.org/r/20200818120526.702120-2-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/ucma.c