summaryrefslogtreecommitdiffstats
path: root/net/ethtool
diff options
context:
space:
mode:
authorDaniil Tatianin <d-tatianin@yandex-team.ru>2022-12-26 12:48:23 +0100
committerDavid S. Miller <davem@davemloft.net>2022-12-28 12:55:24 +0100
commit9deb1e9fb88b1120a908676fa33bdf9e2eeaefce (patch)
tree7a0c536e3fc4da92da35d515b1fa071460f63758 /net/ethtool
parentMerge branch 'bnxt_en-fixes' (diff)
downloadlinux-9deb1e9fb88b1120a908676fa33bdf9e2eeaefce.tar.xz
linux-9deb1e9fb88b1120a908676fa33bdf9e2eeaefce.zip
net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats
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>
Diffstat (limited to 'net/ethtool')
-rw-r--r--net/ethtool/ioctl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index c2f1a542e6fa..932fa8225b2f 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -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;