Skip to content

Commit

Permalink
net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats
Browse files Browse the repository at this point in the history
It's not very useful to copy back an empty ethtool_stats struct and
return 0 if we didn't actually have any stats. This also allows for
further simplification of this function in the future commits.

Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Daniil Tatianin authored and David S. Miller committed Dec 28, 2022
1 parent 8ac718c commit 9deb1e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/ethtool/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,8 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
return n_stats;
if (n_stats > S32_MAX / sizeof(u64))
return -ENOMEM;
WARN_ON_ONCE(!n_stats);
if (WARN_ON_ONCE(!n_stats))
return -EOPNOTSUPP;

if (copy_from_user(&stats, useraddr, sizeof(stats)))
return -EFAULT;
Expand Down

0 comments on commit 9deb1e9

Please sign in to comment.