summaryrefslogtreecommitdiff
path: root/net/ethtool/ioctl.c
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2020-05-15 12:49:00 -0700
committerDavid S. Miller <davem@davemloft.net>2020-05-16 13:56:30 -0700
commit7be92514b99c15b89def6d72bbc84c354f89a025 (patch)
tree7a3f34fe230881653b8bf6a7cd18cbcdc32dd7a2 /net/ethtool/ioctl.c
parenta0c1d0eafd1ef1ada3b588ea205e5bc37ae0d8d9 (diff)
ethtool: check if there is at least one channel for TX/RX in the core
Having a channel config with no ability to RX or TX traffic is clearly wrong. Check for this in the core so the drivers don't have to. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Michal Kubecek <mkubecek@suse.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethtool/ioctl.c')
-rw-r--r--net/ethtool/ioctl.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 52102ab1709b..a574d60111fa 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1676,6 +1676,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) &&