]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
RDMA/iwcm: Don't touch cmid after dropping reference
authorSteve Wise <swise@opengridcomputing.com>
Tue, 23 Apr 2013 16:17:14 +0000 (16:17 +0000)
committerRoland Dreier <roland@purestorage.com>
Thu, 25 Apr 2013 00:47:33 +0000 (17:47 -0700)
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>
drivers/infiniband/core/iwcm.c

index 0bb99bb38809f12e7a1c2b7559f77e9a6744c9d0..c47c2034ca71f9a95f3153fbc31756fc34b1fde0 100644 (file)
@@ -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);