From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C3CCA00C5; Tue, 15 Feb 2022 13:56:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B51154115C; Tue, 15 Feb 2022 13:56:03 +0100 (CET) Received: from office2.cesnet.cz (office2.cesnet.cz [195.113.144.244]) by mails.dpdk.org (Postfix) with ESMTP id 5D8C54113F; Tue, 15 Feb 2022 13:56:02 +0100 (CET) Received: from emil.fit.vutbr.cz (unknown [IPv6:2001:67c:1220:80c:eb:e00e:9e81:ff5f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id 2867240006D; Tue, 15 Feb 2022 13:56:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2-2020; t=1644929762; bh=kkDdK0hKuxcH2KaNM8dm6WTHcedyW3eq67/zLGz0uP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Llzmi8gMEBPLCvqqL9o7mH3om5ODG4zp8Tb8DtrXiAzjCG/kAaXycxzZSd7mNY3vy ofSCFXH2Y9Q5qs9jEb8TlYYyRPODgSS3xtoOakqGUktWpz2tQDs2UvgpaYLQJiimkx ZVQk8ALeJh52GnDW8q8RzPXuK8CHJj2M9IDkaSwRI8sTaeL1xXTs+SEwAZ0BDlfKr4 pur4KpdCugPVlmKTqH0Yc/WYtoaXfCN9xNvDeDvwsWR4CG/YOYEZ69HolOHNHZfkv9 pz0/iCa/vO9uUI0w0jxZulqxTEc/n1h2sWkDNgbAXYQavxbrK3Iq1/9zmixJh5J/yq Jk2szCX5UN3Xg== From: spinler@cesnet.cz To: dev@dpdk.org Cc: Martin Spinler , cernay@netcope.com, stable@dpdk.org Subject: [PATCH v2 1/5] net/nfb: fix array indexes in deinit functions Date: Tue, 15 Feb 2022 13:55:39 +0100 Message-Id: <20220215125543.142108-2-spinler@cesnet.cz> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220215125543.142108-1-spinler@cesnet.cz> References: <20220214112541.29782-1-spinler@cesnet.cz> <20220215125543.142108-1-spinler@cesnet.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Martin Spinler 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: cernay@netcope.com Cc: stable@dpdk.org Signed-off-by: Martin Spinler --- 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