patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH 1/3] net/af_packet: fix check of file descriptors
       [not found] <cover.1594037787.git.wangyunjian@huawei.com>
@ 2020-07-06 12:27 ` wangyunjian
  2020-07-06 12:27 ` [dpdk-stable] [dpdk-dev] [PATCH 2/3] net/af_packet: fix mem leak on init failure wangyunjian
  2020-07-06 12:28 ` [dpdk-stable] [dpdk-dev] [PATCH 3/3] net/af_packet: fix wrong munmap " wangyunjian
  2 siblings, 0 replies; 3+ messages in thread
From: wangyunjian @ 2020-07-06 12:27 UTC (permalink / raw)
  To: dev; +Cc: linville, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

Zero is a valid fd. It will fail to check the fd if the fd is zero.

Fixes: 527740ccfaec ("af_packet: fix some leaks")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 22feb72..361b5d5 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -645,6 +645,8 @@ struct pmd_internals {
 	for (q = 0; q < nb_queues; q++) {
 		(*internals)->rx_queue[q].map = MAP_FAILED;
 		(*internals)->tx_queue[q].map = MAP_FAILED;
+		(*internals)->rx_queue[q].sockfd = -1;
+		(*internals)->tx_queue[q].sockfd = -1;
 	}
 
 	req = &((*internals)->req);
@@ -848,7 +850,7 @@ struct pmd_internals {
 
 		rte_free((*internals)->rx_queue[q].rd);
 		rte_free((*internals)->tx_queue[q].rd);
-		if (((*internals)->rx_queue[q].sockfd != 0) &&
+		if (((*internals)->rx_queue[q].sockfd >= 0) &&
 			((*internals)->rx_queue[q].sockfd != qsockfd))
 			close((*internals)->rx_queue[q].sockfd);
 	}
-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [dpdk-dev] [PATCH 2/3] net/af_packet: fix mem leak on init failure
       [not found] <cover.1594037787.git.wangyunjian@huawei.com>
  2020-07-06 12:27 ` [dpdk-stable] [dpdk-dev] [PATCH 1/3] net/af_packet: fix check of file descriptors wangyunjian
@ 2020-07-06 12:27 ` wangyunjian
  2020-07-06 12:28 ` [dpdk-stable] [dpdk-dev] [PATCH 3/3] net/af_packet: fix wrong munmap " wangyunjian
  2 siblings, 0 replies; 3+ messages in thread
From: wangyunjian @ 2020-07-06 12:27 UTC (permalink / raw)
  To: dev; +Cc: linville, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

Add missing code to free memory when the device initialization fails.

Fixes: ccd37d341e8d ("net/af_packet: remove queue number limitation")
Fixes: 5f19dee604ed ("drivers/net: do not use private ethdev data")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 361b5d5..be3fabb 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -637,9 +637,7 @@ struct pmd_internals {
 						sizeof(struct pkt_tx_queue),
 						0, numa_node);
 	if (!(*internals)->rx_queue || !(*internals)->tx_queue) {
-		rte_free((*internals)->rx_queue);
-		rte_free((*internals)->tx_queue);
-		return -1;
+		goto free_internals;
 	}
 
 	for (q = 0; q < nb_queues; q++) {
@@ -664,20 +662,20 @@ struct pmd_internals {
 		PMD_LOG(ERR,
 			"%s: I/F name too long (%s)",
 			name, pair->value);
-		return -1;
+		goto free_internals;
 	}
 	if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) {
 		PMD_LOG_ERRNO(ERR, "%s: ioctl failed (SIOCGIFINDEX)", name);
-		return -1;
+		goto free_internals;
 	}
 	(*internals)->if_name = strdup(pair->value);
 	if ((*internals)->if_name == NULL)
-		return -1;
+		goto free_internals;
 	(*internals)->if_index = ifr.ifr_ifindex;
 
 	if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {
 		PMD_LOG_ERRNO(ERR, "%s: ioctl failed (SIOCGIFHWADDR)", name);
-		return -1;
+		goto free_internals;
 	}
 	memcpy(&(*internals)->eth_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
 
@@ -701,7 +699,7 @@ struct pmd_internals {
 			PMD_LOG_ERRNO(ERR,
 				"%s: could not open AF_PACKET socket",
 				name);
-			return -1;
+			goto error;
 		}
 
 		tpver = TPACKET_V2;
@@ -854,6 +852,9 @@ struct pmd_internals {
 			((*internals)->rx_queue[q].sockfd != qsockfd))
 			close((*internals)->rx_queue[q].sockfd);
 	}
+free_internals:
+	rte_free((*internals)->rx_queue);
+	rte_free((*internals)->tx_queue);
 	free((*internals)->if_name);
 	rte_free(*internals);
 	return -1;
-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [dpdk-dev] [PATCH 3/3] net/af_packet: fix wrong munmap on init failure
       [not found] <cover.1594037787.git.wangyunjian@huawei.com>
  2020-07-06 12:27 ` [dpdk-stable] [dpdk-dev] [PATCH 1/3] net/af_packet: fix check of file descriptors wangyunjian
  2020-07-06 12:27 ` [dpdk-stable] [dpdk-dev] [PATCH 2/3] net/af_packet: fix mem leak on init failure wangyunjian
@ 2020-07-06 12:28 ` wangyunjian
  2 siblings, 0 replies; 3+ messages in thread
From: wangyunjian @ 2020-07-06 12:28 UTC (permalink / raw)
  To: dev; +Cc: linville, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

Add a missing available check and fix the wrong address passed
to munmap on init failure.

Fixes: dd6590fe2fd7 ("af_packet: fix possible memory leak")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index be3fabb..4d2e1f6 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -843,8 +843,9 @@ struct pmd_internals {
 	if (qsockfd != -1)
 		close(qsockfd);
 	for (q = 0; q < nb_queues; q++) {
-		munmap((*internals)->rx_queue[q].map,
-		       2 * req->tp_block_size * req->tp_block_nr);
+		if ((*internals)->rx_queue[q].map != MAP_FAILED)
+			munmap((*internals)->rx_queue[q].map,
+			       2 * req->tp_block_size * req->tp_block_nr);
 
 		rte_free((*internals)->rx_queue[q].rd);
 		rte_free((*internals)->tx_queue[q].rd);
-- 
1.8.3.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-06 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1594037787.git.wangyunjian@huawei.com>
2020-07-06 12:27 ` [dpdk-stable] [dpdk-dev] [PATCH 1/3] net/af_packet: fix check of file descriptors wangyunjian
2020-07-06 12:27 ` [dpdk-stable] [dpdk-dev] [PATCH 2/3] net/af_packet: fix mem leak on init failure wangyunjian
2020-07-06 12:28 ` [dpdk-stable] [dpdk-dev] [PATCH 3/3] net/af_packet: fix wrong munmap " wangyunjian

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git