From: Martin Spinler <spin...@cesnet.cz>

The indexes in the for cycle were wrongly used and
the code accessed outside of the rxmac/txmac array.

Fixes: 6435f9a0ac22 ("net/nfb: add new netcope driver")
Cc: cer...@netcope.com
Cc: sta...@dpdk.org
Signed-off-by: Martin Spinler <spin...@cesnet.cz>
---
 drivers/net/nfb/nfb_ethdev.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index 3c39937816..0b27fe78cc 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -77,9 +77,10 @@ static void
 nfb_nc_rxmac_deinit(struct nc_rxmac *rxmac[RTE_MAX_NC_RXMAC],
        uint16_t max_rxmac)
 {
-       for (; max_rxmac > 0; --max_rxmac) {
-               nc_rxmac_close(rxmac[max_rxmac]);
-               rxmac[max_rxmac] = NULL;
+       uint16_t i;
+       for (i = 0; i < max_rxmac; i++) {
+               nc_rxmac_close(rxmac[i]);
+               rxmac[i] = NULL;
        }
 }
 
@@ -95,9 +96,10 @@ static void
 nfb_nc_txmac_deinit(struct nc_txmac *txmac[RTE_MAX_NC_TXMAC],
        uint16_t max_txmac)
 {
-       for (; max_txmac > 0; --max_txmac) {
-               nc_txmac_close(txmac[max_txmac]);
-               txmac[max_txmac] = NULL;
+       uint16_t i;
+       for (i = 0; i < max_txmac; i++) {
+               nc_txmac_close(txmac[i]);
+               txmac[i] = NULL;
        }
 }
 
-- 
2.35.1

Reply via email to