提交 7d2bd999 编写于 作者: D Daniil Tatianin 提交者: sanglipeng

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

stable inclusion
from stable-v5.10.165
commit 0040e48492f375a63ab68df35be4d228e64b41c8
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7T7G4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0040e48492f375a63ab68df35be4d228e64b41c8

--------------------------------

[ Upstream commit 9deb1e9f ]

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: NDaniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 4510735a
......@@ -2065,7 +2065,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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册