[openib-general] [PATCH] IB/ucm: fix deadlock in cleanup

Michael S. Tsirkin mst at mellanox.co.il
Wed Nov 15 01:43:48 PST 2006


ib_ucm_cleanup_events has file_mutex while calling ib_destroy_cm_id.
It seems this can deadlock since ib_destroy_cm_id flushes event
handlers, and ib_ucm_event_handler needs file_mutex, too.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

---

I'll be testing the following the next night - but it seems a right
thing to do regardless of whether it fixes the issues I reported
earlier. Sean, does this make sense to you? If yes, please ack for 2.6.19.

diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index ad4f4d5..0128288 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -161,12 +161,14 @@ static void ib_ucm_cleanup_events(struct
 				    struct ib_ucm_event, ctx_list);
 		list_del(&uevent->file_list);
 		list_del(&uevent->ctx_list);
+		mutex_unlock(&ctx->file->file_mutex);
 
 		/* clear incoming connections. */
 		if (ib_ucm_new_cm_id(uevent->resp.event))
 			ib_destroy_cm_id(uevent->cm_id);
 
 		kfree(uevent);
+		mutex_lock(&ctx->file->file_mutex);
 	}
 	mutex_unlock(&ctx->file->file_mutex);
 }



-- 
MST




More information about the general mailing list