[3/3] net/af_packet: fix wrong munmap on init failure
diff mbox series

Message ID e4ebc289269ab87d0fa77e9da8f79131e34070ee.1594037787.git.wangyunjian@huawei.com
State Accepted
Delegated to: Ferruh Yigit
Headers show
Series
  • fixes for af_packet driver
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/travis-robot success Travis build: passed
ci/checkpatch success coding style OK

Commit Message

wangyunjian July 6, 2020, 12:28 p.m. UTC
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(-)

Patch
diff mbox series

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);