Merge tag 'v3.10.106' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / infiniband / ulp / ipoib / ipoib_cm.c
index aa9ad2d70ddda4d0ce8bad676cc04ae9112a7522..c781c7c633fdbf2b27a3bc70ca578511a2eb6839 100644 (file)
@@ -1482,12 +1482,14 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
 
        ret = ipoib_set_mode(dev, buf);
 
-       rtnl_unlock();
-
-       if (!ret)
-               return count;
+       /* 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();
 
-       return ret;
+       return (!ret || ret == -EBUSY) ? count : ret;
 }
 
 static DEVICE_ATTR(mode, S_IWUSR | S_IRUGO, show_mode, set_mode);