aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2020-08-18 15:05:14 +0300
committerJason Gunthorpe <jgg@nvidia.com>2020-08-27 08:38:13 -0300
commit07e266a7753d952978f317aa2b206b4da4769567 (patch)
treeee5ff2bc80acfb300e0be319b9c0e80c64abbb04 /drivers
parentRDMA/ucma: Fix refcount 0 incr in ucma_get_ctx() (diff)
downloadlinux-dev-07e266a7753d952978f317aa2b206b4da4769567.tar.xz
linux-dev-07e266a7753d952978f317aa2b206b4da4769567.zip
RDMA/ucma: Remove unnecessary locking of file->ctx_list in close
During the file_operations release function it is already not possible that write() can be running concurrently, remove the extra locking around the ctx_list. Link: https://lore.kernel.org/r/20200818120526.702120-3-leon@kernel.org Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/core/ucma.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 625168563443..9b019f31743d 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -1824,12 +1824,17 @@ static int ucma_close(struct inode *inode, struct file *filp)
struct ucma_file *file = filp->private_data;
struct ucma_context *ctx, *tmp;
- mutex_lock(&file->mut);
+ /*
+ * ctx_list can only be mutated under the write(), which is no longer
+ * possible, so no locking needed.
+ */
list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) {
+ xa_erase(&ctx_table, ctx->id);
+
+ mutex_lock(&file->mut);
ctx->destroying = 1;
mutex_unlock(&file->mut);
- xa_erase(&ctx_table, ctx->id);
flush_workqueue(file->close_wq);
/* At that step once ctx was marked as destroying and workqueue
* was flushed we are safe from any inflights handlers that
@@ -1849,9 +1854,7 @@ static int ucma_close(struct inode *inode, struct file *filp)
}
ucma_free_ctx(ctx);
- mutex_lock(&file->mut);
}
- mutex_unlock(&file->mut);
destroy_workqueue(file->close_wq);
kfree(file);
return 0;