[RFC 6/8] net/enetfc: fix array out of bounds warning
Stephen Hemminger
stephen at networkplumber.org
Tue Jun 7 19:17:44 CEST 2022
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 at networkplumber.org>
---
drivers/net/enetfec/enet_ethdev.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/enetfec/enet_ethdev.c b/drivers/net/enetfec/enet_ethdev.c
index 714f8ac7eccc..4956235a10a6 100644
--- a/drivers/net/enetfec/enet_ethdev.c
+++ b/drivers/net/enetfec/enet_ethdev.c
@@ -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) {
--
2.35.1
More information about the dev
mailing list