Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19304ffb authored by Daniil Tatianin's avatar Daniil Tatianin Committed by Greg Kroah-Hartman
Browse files

net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats



[ Upstream commit 9deb1e9fb88b1120a908676fa33bdf9e2eeaefce ]

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: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 4de1a5af
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1947,7 +1947,8 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
		return n_stats;
		return n_stats;
	if (n_stats > S32_MAX / sizeof(u64))
	if (n_stats > S32_MAX / sizeof(u64))
		return -ENOMEM;
		return -ENOMEM;
	WARN_ON_ONCE(!n_stats);
	if (WARN_ON_ONCE(!n_stats))
		return -EOPNOTSUPP;


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