net: devlink: don't take devlink_mutex for devlink_compat_*
authorJiri Pirko <jiri@mellanox.com>
Sun, 24 Mar 2019 10:14:29 +0000 (11:14 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 24 Mar 2019 18:55:31 +0000 (14:55 -0400)
The netdevice is guaranteed to not disappear so we can rely that
devlink_port and devlink won't disappear as well. No need to take
devlink_mutex so don't take it here.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/devlink.c

index bd4d8bce658d7841f394e2e6b72290cba4dceaad..65c1cf4a5764ea1cd6962d3e2f9ca8162bb1f421 100644 (file)
@@ -6407,17 +6407,15 @@ void devlink_compat_running_version(struct net_device *dev,
        dev_hold(dev);
        rtnl_unlock();
 
-       mutex_lock(&devlink_mutex);
        devlink = netdev_to_devlink(dev);
        if (!devlink || !devlink->ops->info_get)
-               goto unlock_list;
+               goto out;
 
        mutex_lock(&devlink->lock);
        __devlink_compat_running_version(devlink, buf, len);
        mutex_unlock(&devlink->lock);
-unlock_list:
-       mutex_unlock(&devlink_mutex);
 
+out:
        rtnl_lock();
        dev_put(dev);
 }
@@ -6425,22 +6423,22 @@ unlock_list:
 int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
 {
        struct devlink *devlink;
-       int ret = -EOPNOTSUPP;
+       int ret;
 
        dev_hold(dev);
        rtnl_unlock();
 
-       mutex_lock(&devlink_mutex);
        devlink = netdev_to_devlink(dev);
-       if (!devlink || !devlink->ops->flash_update)
-               goto unlock_list;
+       if (!devlink || !devlink->ops->flash_update) {
+               ret = -EOPNOTSUPP;
+               goto out;
+       }
 
        mutex_lock(&devlink->lock);
        ret = devlink->ops->flash_update(devlink, file_name, NULL, NULL);
        mutex_unlock(&devlink->lock);
-unlock_list:
-       mutex_unlock(&devlink_mutex);
 
+out:
        rtnl_lock();
        dev_put(dev);