[RFC,6/8] net/enetfc: fix array out of bounds warning
Checks
Commit Message
With gcc-12 it detects that this function could be passed a
queue > 1 which would cause out of bounds access.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/enetfec/enet_ethdev.c | 5 +++++
1 file changed, 5 insertions(+)
@@ -454,6 +454,11 @@ enetfec_rx_queue_setup(struct rte_eth_dev *dev,
return -EINVAL;
}
+ if (queue_idx >= ENETFEC_MAX_Q) {
+ ENETFEC_PMD_ERR("Only %u receive queues supported", ENETFEC_MAX_Q);
+ return -EINVAL;
+ }
+
/* allocate receive queue */
rxq = rte_zmalloc(NULL, sizeof(*rxq), RTE_CACHE_LINE_SIZE);
if (rxq == NULL) {