RDMA/ucma: Fix error cases around ucma_alloc_ctx()
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 18 Aug 2020 12:05:16 +0000 (15:05 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 27 Aug 2020 11:38:14 +0000 (08:38 -0300)
commit620db1a1183d69cc49981ee59c9207e53befeae4
tree3500ef6c2ff42753c83bdb08fa9c31638eba70e9
parentc07e12d8e9b4b6e532f52ecc89e52d10f3f8e8f5
RDMA/ucma: Fix error cases around ucma_alloc_ctx()

The store to ctx->cm_id was based on the idea that _ucma_find_context()
would not return the ctx until it was fully setup.

Without locking this doesn't work properly.

Split things so that the xarray is allocated with NULL to reserve the ID
and once everything is final set the cm_id and store.

Along the way this shows that the error unwind in ucma_get_event() if a
new ctx is created is wrong, fix it up.

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