IB/IPoIB: Fix race between ipoib_remove_one to sysfs functions
[cascardo/linux.git] / drivers / infiniband / ulp / ipoib / ipoib_cm.c
index b2f4283..951d9ab 100644 (file)
@@ -1486,6 +1486,10 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
 {
        struct net_device *dev = to_net_dev(d);
        int ret;
+       struct ipoib_dev_priv *priv = netdev_priv(dev);
+
+       if (test_bit(IPOIB_FLAG_GOING_DOWN, &priv->flags))
+               return -EPERM;
 
        if (!rtnl_trylock())
                return restart_syscall();