IB/ipoib: Fix deadlock between rmmod and set_mode

am: 10beca5374

Change-Id: I9eaddaaac8da4e38418436e47eacb36306302b31
This commit is contained in:
Feras Daoud 2017-03-15 02:10:30 +00:00 committed by android-build-merger
commit b576323b87
2 changed files with 9 additions and 9 deletions

View file

@ -1488,12 +1488,14 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
ret = ipoib_set_mode(dev, buf); ret = ipoib_set_mode(dev, buf);
rtnl_unlock(); /* The assumption is that the function ipoib_set_mode returned
* with the rtnl held by it, if not the value -EBUSY returned,
* then no need to rtnl_unlock
*/
if (ret != -EBUSY)
rtnl_unlock();
if (!ret) return (!ret || ret == -EBUSY) ? count : ret;
return count;
return ret;
} }
static DEVICE_ATTR(mode, S_IWUSR | S_IRUGO, show_mode, set_mode); static DEVICE_ATTR(mode, S_IWUSR | S_IRUGO, show_mode, set_mode);

View file

@ -464,8 +464,7 @@ int ipoib_set_mode(struct net_device *dev, const char *buf)
priv->tx_wr.wr.send_flags &= ~IB_SEND_IP_CSUM; priv->tx_wr.wr.send_flags &= ~IB_SEND_IP_CSUM;
ipoib_flush_paths(dev); ipoib_flush_paths(dev);
rtnl_lock(); return (!rtnl_trylock()) ? -EBUSY : 0;
return 0;
} }
if (!strcmp(buf, "datagram\n")) { if (!strcmp(buf, "datagram\n")) {
@ -474,8 +473,7 @@ int ipoib_set_mode(struct net_device *dev, const char *buf)
dev_set_mtu(dev, min(priv->mcast_mtu, dev->mtu)); dev_set_mtu(dev, min(priv->mcast_mtu, dev->mtu));
rtnl_unlock(); rtnl_unlock();
ipoib_flush_paths(dev); ipoib_flush_paths(dev);
rtnl_lock(); return (!rtnl_trylock()) ? -EBUSY : 0;
return 0;
} }
return -EINVAL; return -EINVAL;