Skip to content

Commit fd47785

Browse files
d-tatianindavem330
authored andcommitted
net/ethtool/ioctl: remove if n_stats checks from ethtool_get_phy_stats
Now that we always early return if we don't have any stats we can remove these checks as they're no longer necessary. Signed-off-by: Daniil Tatianin <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9deb1e9 commit fd47785

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

net/ethtool/ioctl.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,28 +2107,24 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
21072107

21082108
stats.n_stats = n_stats;
21092109

2110-
if (n_stats) {
2111-
data = vzalloc(array_size(n_stats, sizeof(u64)));
2112-
if (!data)
2113-
return -ENOMEM;
2110+
data = vzalloc(array_size(n_stats, sizeof(u64)));
2111+
if (!data)
2112+
return -ENOMEM;
21142113

2115-
if (phydev && !ops->get_ethtool_phy_stats &&
2116-
phy_ops && phy_ops->get_stats) {
2117-
ret = phy_ops->get_stats(phydev, &stats, data);
2118-
if (ret < 0)
2119-
goto out;
2120-
} else {
2121-
ops->get_ethtool_phy_stats(dev, &stats, data);
2122-
}
2114+
if (phydev && !ops->get_ethtool_phy_stats &&
2115+
phy_ops && phy_ops->get_stats) {
2116+
ret = phy_ops->get_stats(phydev, &stats, data);
2117+
if (ret < 0)
2118+
goto out;
21232119
} else {
2124-
data = NULL;
2120+
ops->get_ethtool_phy_stats(dev, &stats, data);
21252121
}
21262122

21272123
ret = -EFAULT;
21282124
if (copy_to_user(useraddr, &stats, sizeof(stats)))
21292125
goto out;
21302126
useraddr += sizeof(stats);
2131-
if (n_stats && copy_to_user(useraddr, data, array_size(n_stats, sizeof(u64))))
2127+
if (copy_to_user(useraddr, data, array_size(n_stats, sizeof(u64))))
21322128
goto out;
21332129
ret = 0;
21342130

0 commit comments

Comments
 (0)