aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Wise <swise@opengridcomputing.com>2013-04-23 12:17:14 -0400
committerRoland Dreier <roland@purestorage.com>2013-04-24 20:47:33 -0400
commite413a823f60b582af471f0079eb99f50d34b0da7 (patch)
tree945c3a57df72e353f03a5ad3b7623df219dcab56
parentcc529c0d72bd2490801ce324caf2ea0a0c1d7b1e (diff)
RDMA/iwcm: Don't touch cmid after dropping reference
The 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 we know it's safe to re-acquire the lock. Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r--drivers/infiniband/core/iwcm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 0bb99bb38809..c47c2034ca71 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -878,6 +878,8 @@ static void cm_work_handler(struct work_struct *_work)
878 } 878 }
879 return; 879 return;
880 } 880 }
881 if (empty)
882 return;
881 spin_lock_irqsave(&cm_id_priv->lock, flags); 883 spin_lock_irqsave(&cm_id_priv->lock, flags);
882 } 884 }
883 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 885 spin_unlock_irqrestore(&cm_id_priv->lock, flags);