Skip to contentSkip to conversation

RDMA/IWCM: don't access the cm_id after dereferencing it.

PATCH Applied Steve Wise 2 participants 2 messages Mar 4, 2008 – Mar 11, 2008

Subsystems (3)
lore
Share & tools
lore

Steve Wise

author
#0 lore raw

PATCH 1/1 RDMA/IWCM: don't access the cm_id after dereferencing it.

RDMA/IWCM: don't access the cm_id after dereferencing it.

cm_work_handler() can access cm_id_priv after it was potentially freed by iwch_deref_id(). The fix is to note whether IWCM_F_CALLBACK_DESTROY is set before dereferencing. Then if it was set, free the cm_id on this thread.

---

 drivers/infiniband/core/iwcm.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/core/iwcm.c +3 -2
index 223b1aa..81c9195 100644
@@ -839,6 +839,7 @@ static void cm_work_handler(struct work_struct *_work)
 	unsigned long flags;
 	int empty;
 	int ret = 0;
+	int destroy_id;
 
 	spin_lock_irqsave(&cm_id_priv->lock, flags);
 	empty = list_empty(&cm_id_priv->work_list);
@@ -857,9 +858,9 @@ static void cm_work_handler(struct work_struct *_work)
 			destroy_cm_id(&cm_id_priv->id);
 		}
 		BUG_ON(atomic_read(&cm_id_priv->refcount)==0);
+		destroy_id = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
 		if (iwcm_deref_id(cm_id_priv)) {
-			if (test_bit(IWCM_F_CALLBACK_DESTROY,
-				     &cm_id_priv->flags)) {
+			if (destroy_id) {
 				BUG_ON(!list_empty(&cm_id_priv->work_list));
 				free_cm_id(cm_id_priv);
 			}