]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: Reoder rxq_idx check in __net_mp_open_rxq()
authorYue Haibing <yuehaibing@huawei.com>
Tue, 24 Jun 2025 14:01:59 +0000 (22:01 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 25 Jun 2025 23:53:51 +0000 (16:53 -0700)
array_index_nospec() clamp the rxq_idx within the range of
[0, dev->real_num_rx_queues), move the check before it.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Link: https://patch.msgid.link/20250624140159.3929503-1-yuehaibing@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/netdev_rx_queue.c

index d126f10197bf471be67365b470270b0f9dcf7494..3bf1151d806107eb12cb7b3a00951b37e54910fe 100644 (file)
@@ -97,14 +97,12 @@ int __net_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx,
        if (!netdev_need_ops_lock(dev))
                return -EOPNOTSUPP;
 
-       if (rxq_idx >= dev->real_num_rx_queues)
-               return -EINVAL;
-       rxq_idx = array_index_nospec(rxq_idx, dev->real_num_rx_queues);
-
        if (rxq_idx >= dev->real_num_rx_queues) {
                NL_SET_ERR_MSG(extack, "rx queue index out of range");
                return -ERANGE;
        }
+       rxq_idx = array_index_nospec(rxq_idx, dev->real_num_rx_queues);
+
        if (dev->cfg->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED) {
                NL_SET_ERR_MSG(extack, "tcp-data-split is disabled");
                return -EINVAL;