Skip to content

Commit 9deb1e9

Browse files
d-tatianindavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8ac718c commit 9deb1e9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ethtool/ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,8 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
20992099
return n_stats;
21002100
if (n_stats > S32_MAX / sizeof(u64))
21012101
return -ENOMEM;
2102-
WARN_ON_ONCE(!n_stats);
2102+
if (WARN_ON_ONCE(!n_stats))
2103+
return -EOPNOTSUPP;
21032104

21042105
if (copy_from_user(&stats, useraddr, sizeof(stats)))
21052106
return -EFAULT;

0 commit comments

Comments
 (0)