net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats
[platform/kernel/linux-rpi.git] / net / ethtool / ioctl.c
index 6991d77..939c63d 100644 (file)
@@ -2074,7 +2074,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;