@@ -545,6 +545,7 @@ static void ucma_cleanup_mc_events(struct ucma_multicast *mc)
{
struct ucma_event *uevent, *tmp;
+ rdma_lock_handler(mc->ctx->cm_id);
list_for_each_entry_safe(uevent, tmp, &mc->ctx->file->event_list, list) {
if (uevent->mc != mc)
continue;
@@ -552,6 +553,7 @@ static void ucma_cleanup_mc_events(struct ucma_multicast *mc)
list_del(&uevent->list);
kfree(uevent);
}
+ rdma_unlock_handler(mc->ctx->cm_id);
}
/*
@@ -1548,7 +1550,7 @@ static ssize_t ucma_leave_multicast(struct ucma_file *file,
mc = xa_load(&multicast_table, cmd.id);
if (!mc)
mc = ERR_PTR(-ENOENT);
- else if (mc->ctx->file != file)
+ else if (READ_ONCE(mc->ctx->file) != file)
mc = ERR_PTR(-EINVAL);
else if (!atomic_inc_not_zero(&mc->ctx->ref))
mc = ERR_PTR(-ENXIO);
@@ -1643,6 +1645,7 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
goto file_put;
}
+ rdma_lock_handler(ctx->cm_id);
cur_file = ctx->file;
if (cur_file == new_file) {
mutex_lock(&cur_file->mut);
@@ -1671,6 +1674,7 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
&resp, sizeof(resp)))
ret = -EFAULT;
+ rdma_unlock_handler(ctx->cm_id);
ucma_put_ctx(ctx);
file_put:
fdput(f);