Skip to content

Commit f6fa45d

Browse files
Yue Haibingkuba-moo
authored andcommitted
net: Reoder rxq_idx check in __net_mp_open_rxq()
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 <[email protected]> Reviewed-by: Mina Almasry <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3b3ccf9 commit f6fa45d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/core/netdev_rx_queue.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,12 @@ int __net_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx,
9797
if (!netdev_need_ops_lock(dev))
9898
return -EOPNOTSUPP;
9999

100-
if (rxq_idx >= dev->real_num_rx_queues)
101-
return -EINVAL;
102-
rxq_idx = array_index_nospec(rxq_idx, dev->real_num_rx_queues);
103-
104100
if (rxq_idx >= dev->real_num_rx_queues) {
105101
NL_SET_ERR_MSG(extack, "rx queue index out of range");
106102
return -ERANGE;
107103
}
104+
rxq_idx = array_index_nospec(rxq_idx, dev->real_num_rx_queues);
105+
108106
if (dev->cfg->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED) {
109107
NL_SET_ERR_MSG(extack, "tcp-data-split is disabled");
110108
return -EINVAL;

0 commit comments

Comments
 (0)