Skip to content

Commit

Permalink
ethtool: move netif_device_present check from ethnl_parse_header_dev_…
Browse files Browse the repository at this point in the history
…get to ethnl_ops_begin

If device is runtime-suspended and not accessible then it may be
flagged as not present. If checking whether device is present is
done too early then we may bail out before we have the chance to
runtime-resume the device. Therefore move this check to
ethnl_ops_begin(). This is in preparation of a follow-up patch
that tries to runtime-resume the device before executing ethtool
ops.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Heiner Kallweit authored and David S. Miller committed Aug 3, 2021
1 parent c5ab51d commit 41107ac
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/ethtool/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ const struct nla_policy ethnl_header_policy_stats[] = {

int ethnl_ops_begin(struct net_device *dev)
{
if (dev && dev->ethtool_ops->begin)
if (!dev)
return 0;

if (!netif_device_present(dev))
return -ENODEV;

if (dev->ethtool_ops->begin)
return dev->ethtool_ops->begin(dev);
else
return 0;
Expand Down Expand Up @@ -115,12 +121,6 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
return -EINVAL;
}

if (dev && !netif_device_present(dev)) {
dev_put(dev);
NL_SET_ERR_MSG(extack, "device not present");
return -ENODEV;
}

req_info->dev = dev;
req_info->flags = flags;
return 0;
Expand Down

0 comments on commit 41107ac

Please sign in to comment.