Skip to contentSkip to conversation

iw_cm: Don't touch cmid after dereferencing it.

PATCH New Steve Wise 1 participant 1 message Apr 23, 2013 InfiniBand

lore
Share & tools
lore

Steve Wise

author
#0 lore raw

PATCH 1/1 iw_cm: Don't touch cmid after dereferencing it.

Function cm_work_handler() cannot touch the cm_id after it derefs it because it might be freed on another concurrent thread. If there are more work items queued for this cm_id, then we know there must be more references because they are added when the work items are queued. So in the while loop inside cm_work_handler(), after derefing, if the queue is empty, then exit the function. Otherwise you know its safe to re-acquire the lock.

---

 drivers/infiniband/core/iwcm.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/infiniband/core/iwcm.c +2 -0
index 0bb99bb..c47c203 100644
@@ -878,6 +878,8 @@ static void cm_work_handler(struct work_struct *_work)
 			}
 			return;
 		}
+		if (empty)
+			return;
 		spin_lock_irqsave(&cm_id_priv->lock, flags);
 	}
 	spin_unlock_irqrestore(&cm_id_priv->lock, flags);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html