Skip to content

Commit

Permalink
RDMA/iwcm: Don't touch cmid after dropping reference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steve Wise authored and Roland Dreier committed Apr 25, 2013
1 parent cc529c0 commit e413a82
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/infiniband/core/iwcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e413a82

Please sign in to comment.