Skip to contentSkip to conversation

RDMA/ucma: Lock the handler in ucma_set_ib_path()

PATCH New Jason Gunthorpe 1 participant 1 message Aug 11

Subsystems (2)
lore
Share & tools
lore

Jason Gunthorpe

author maintainer
#0 lore raw

PATCH 1/1 RDMA/ucma: Lock the handler in ucma_set_ib_path()

ctx->file may only be changed under the handler lock and the xa_lock, which is what stops uevents being queued for a ctx while ucma_migrate_id() moves it to another file.

ucma_set_ib_path() was missing this locking prior to calling ucma_event_handler(). Normally ucma_event_handler() would be called from the CM framework with the handler lock already held.

Add the missing locking.

Fixes 09e328e47a69 ("RDMA/ucma: Fix the locking of ctx->file")
---
 drivers/infiniband/core/ucma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +4 -1
index a29f2d4b8d143d..ac29dfa69bb3a6 100644
@@ -1404,7 +1404,10 @@ static int ucma_set_ib_path(struct ucma_context *ctx,
 
 	memset(&event, 0, sizeof event);
 	event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
-	return ucma_event_handler(ctx->cm_id, &event);
+	rdma_lock_handler(ctx->cm_id);
+	ret = ucma_event_handler(ctx->cm_id, &event);
+	rdma_unlock_handler(ctx->cm_id);
+	return ret;
 }
 
 static int ucma_set_option_ib(struct ucma_context *ctx, int optname,

base-commit: f4cc21c6a8e9d392871477f9fd98d68e5ad80272

Signature · 1 line
2.43.0