Merge tag 'kvm-ppc-next-5.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/paulu...
[linux-2.6-microblaze.git] / net / ethtool / ioctl.c
index 7489262..b5df90c 100644 (file)
@@ -1510,11 +1510,14 @@ static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev,
                                                   void __user *useraddr)
 {
        struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
+       int ret;
 
        if (!dev->ethtool_ops->get_coalesce)
                return -EOPNOTSUPP;
 
-       dev->ethtool_ops->get_coalesce(dev, &coalesce);
+       ret = dev->ethtool_ops->get_coalesce(dev, &coalesce);
+       if (ret)
+               return ret;
 
        if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
                return -EFAULT;
@@ -1669,6 +1672,12 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
 
        dev->ethtool_ops->get_channels(dev, &curr);
 
+       if (channels.rx_count == curr.rx_count &&
+           channels.tx_count == curr.tx_count &&
+           channels.combined_count == curr.combined_count &&
+           channels.other_count == curr.other_count)
+               return 0;
+
        /* ensure new counts are within the maximums */
        if (channels.rx_count > curr.max_rx ||
            channels.tx_count > curr.max_tx ||
@@ -1676,6 +1685,11 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
            channels.other_count > curr.max_other)
                return -EINVAL;
 
+       /* ensure there is at least one RX and one TX channel */
+       if (!channels.combined_count &&
+           (!channels.rx_count || !channels.tx_count))
+               return -EINVAL;
+
        /* ensure the new Rx count fits within the configured Rx flow
         * indirection table settings */
        if (netif_is_rxfh_configured(dev) &&