Commit aabe8488 authored by Shirley Ma's avatar Shirley Ma Committed by Linus Torvalds

[PATCH] IB/ipoib: don't call ipoib_put_ah with lock held

ipoib_put_ah() may call ipoib_free_ah(), which might take the device's lock.
Therefore we need to make sure we don't call ipoib_put_ah() when holding the
lock already.
Signed-off-by: default avatarShirley Ma <xma@us.ibm.com>
Signed-off-by: default avatarRoland Dreier <roland@topspin.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 02413477
...@@ -661,6 +661,7 @@ static void ipoib_neigh_destructor(struct neighbour *n) ...@@ -661,6 +661,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
struct ipoib_neigh *neigh = *to_ipoib_neigh(n); struct ipoib_neigh *neigh = *to_ipoib_neigh(n);
struct ipoib_dev_priv *priv = netdev_priv(n->dev); struct ipoib_dev_priv *priv = netdev_priv(n->dev);
unsigned long flags; unsigned long flags;
struct ipoib_ah *ah = NULL;
ipoib_dbg(priv, ipoib_dbg(priv,
"neigh_destructor for %06x " IPOIB_GID_FMT "\n", "neigh_destructor for %06x " IPOIB_GID_FMT "\n",
...@@ -671,13 +672,16 @@ static void ipoib_neigh_destructor(struct neighbour *n) ...@@ -671,13 +672,16 @@ static void ipoib_neigh_destructor(struct neighbour *n)
if (neigh) { if (neigh) {
if (neigh->ah) if (neigh->ah)
ipoib_put_ah(neigh->ah); ah = neigh->ah;
list_del(&neigh->list); list_del(&neigh->list);
*to_ipoib_neigh(n) = NULL; *to_ipoib_neigh(n) = NULL;
kfree(neigh); kfree(neigh);
} }
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
if (ah)
ipoib_put_ah(ah);
} }
static int ipoib_neigh_setup(struct neighbour *neigh) static int ipoib_neigh_setup(struct neighbour *neigh)
......
...@@ -93,6 +93,8 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast) ...@@ -93,6 +93,8 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
struct ipoib_neigh *neigh, *tmp; struct ipoib_neigh *neigh, *tmp;
unsigned long flags; unsigned long flags;
LIST_HEAD(ah_list);
struct ipoib_ah *ah, *tah;
ipoib_dbg_mcast(netdev_priv(dev), ipoib_dbg_mcast(netdev_priv(dev),
"deleting multicast group " IPOIB_GID_FMT "\n", "deleting multicast group " IPOIB_GID_FMT "\n",
...@@ -101,7 +103,8 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast) ...@@ -101,7 +103,8 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
list_for_each_entry_safe(neigh, tmp, &mcast->neigh_list, list) { list_for_each_entry_safe(neigh, tmp, &mcast->neigh_list, list) {
ipoib_put_ah(neigh->ah); if (neigh->ah)
list_add_tail(&neigh->ah->list, &ah_list);
*to_ipoib_neigh(neigh->neighbour) = NULL; *to_ipoib_neigh(neigh->neighbour) = NULL;
neigh->neighbour->ops->destructor = NULL; neigh->neighbour->ops->destructor = NULL;
kfree(neigh); kfree(neigh);
...@@ -109,6 +112,9 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast) ...@@ -109,6 +112,9 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
list_for_each_entry_safe(ah, tah, &ah_list, list)
ipoib_put_ah(ah);
if (mcast->ah) if (mcast->ah)
ipoib_put_ah(mcast->ah); ipoib_put_ah(mcast->ah);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment