aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/devlink.c
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-02-25 19:34:06 -0800
committerDavid S. Miller <davem@davemloft.net>2019-02-26 08:49:05 -0800
commit1b45ff6c17f1d07c496b08dd602a4aff8fe40848 (patch)
tree8e7cc2289a7e48072dc3db8690e709828debb7d9 /net/core/devlink.c
parentnfp: remove ethtool flashing fallback (diff)
downloadlinux-dev-1b45ff6c17f1d07c496b08dd602a4aff8fe40848.tar.xz
linux-dev-1b45ff6c17f1d07c496b08dd602a4aff8fe40848.zip
devlink: hold a reference to the netdevice around ethtool compat
When ethtool is calling into devlink compat code make sure we have a reference on the netdevice on which the operation was invoked. v3: move the hold/lock logic into devlink_compat_* functions (Florian) Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/devlink.c')
-rw-r--r--net/core/devlink.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 24bfbd2d71e7..ecff6e63bc4d 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6430,6 +6430,9 @@ void devlink_compat_running_version(struct net_device *dev,
{
struct devlink *devlink;
+ dev_hold(dev);
+ rtnl_unlock();
+
mutex_lock(&devlink_mutex);
devlink = netdev_to_devlink(dev);
if (!devlink || !devlink->ops || !devlink->ops->info_get)
@@ -6440,6 +6443,9 @@ void devlink_compat_running_version(struct net_device *dev,
mutex_unlock(&devlink->lock);
unlock_list:
mutex_unlock(&devlink_mutex);
+
+ rtnl_lock();
+ dev_put(dev);
}
int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
@@ -6447,6 +6453,9 @@ int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
struct devlink *devlink;
int ret = -EOPNOTSUPP;
+ dev_hold(dev);
+ rtnl_unlock();
+
mutex_lock(&devlink_mutex);
devlink = netdev_to_devlink(dev);
if (!devlink || !devlink->ops || !devlink->ops->flash_update)
@@ -6457,6 +6466,10 @@ int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
mutex_unlock(&devlink->lock);
unlock_list:
mutex_unlock(&devlink_mutex);
+
+ rtnl_lock();
+ dev_put(dev);
+
return ret;
}