Skip to content

Commit

Permalink
net/nfb: fix array indexes in deinit functions
Browse files Browse the repository at this point in the history
[ upstream commit 8a4c8edb1154a58bad807cdc2ca947773e2ee8f1 ]

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

Fixes: 6435f9a ("net/nfb: add new netcope driver")

Signed-off-by: Martin Spinler <spinler@cesnet.cz>
  • Loading branch information
martinspinler authored and cpaelzer committed Mar 9, 2022
1 parent c641b9a commit 2294078
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions drivers/net/nfb/nfb_ethdev.c
Expand Up @@ -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;
}
}

Expand All @@ -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;
}
}

Expand Down

0 comments on commit 2294078

Please sign in to comment.