1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-16 08:12:53 +08:00

modules/mqnic: Add some additional range enforcement

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich 2023-05-03 16:49:28 -07:00
parent 7cd40a8e1e
commit eecaef6e6f
2 changed files with 13 additions and 2 deletions

View File

@ -161,6 +161,15 @@ static int mqnic_set_channels(struct net_device *ndev,
int port_up = priv->port_up;
int ret = 0;
if (channel->combined_count || channel->other_count)
return -EINVAL;
if (priv->rxq_count > mqnic_res_get_count(priv->interface->rxq_res))
return -EINVAL;
if (priv->txq_count > mqnic_res_get_count(priv->interface->txq_res))
return -EINVAL;
rxq_count = channel->rx_count;
txq_count = channel->tx_count;

View File

@ -570,8 +570,10 @@ struct net_device *mqnic_create_netdev(struct mqnic_if *interface, int index, in
priv->txq_count = min_t(u32, mqnic_res_get_count(interface->txq_res), 256);
priv->rxq_count = min_t(u32, mqnic_res_get_count(interface->rxq_res), num_online_cpus());
priv->tx_ring_size = mqnic_num_txq_entries;
priv->rx_ring_size = mqnic_num_rxq_entries;
priv->tx_ring_size = roundup_pow_of_two(clamp_t(u32, mqnic_num_txq_entries,
MQNIC_MIN_TX_RING_SZ, MQNIC_MAX_TX_RING_SZ));
priv->rx_ring_size = roundup_pow_of_two(clamp_t(u32, mqnic_num_rxq_entries,
MQNIC_MIN_RX_RING_SZ, MQNIC_MAX_RX_RING_SZ));
init_rwsem(&priv->txq_table_sem);
INIT_RADIX_TREE(&priv->txq_table, GFP_KERNEL);