]> git.droids-corp.org - dpdk.git/commitdiff
net/nfb: fix array indexes in deinit functions
authorMartin Spinler <spinler@cesnet.cz>
Tue, 15 Feb 2022 12:55:39 +0000 (13:55 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 15 Feb 2022 13:53:41 +0000 (14:53 +0100)
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: stable@dpdk.org
Signed-off-by: Martin Spinler <spinler@cesnet.cz>
drivers/net/nfb/nfb_ethdev.c

index 3c39937816a45e58644321d073a1f6d291a10d56..0b27fe78cceb643d691c93b90432d97608b80c04 100644 (file)
@@ -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;
        }
 }