From: Yunjian Wang Date: Mon, 6 Jul 2020 12:28:02 +0000 (+0800) Subject: net/af_packet: fix munmap on init failure X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b02e1742ebb5a6c23bea05c4d66b1d380bcd00eb;p=dpdk.git net/af_packet: fix munmap on init failure 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 Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 62945fee20..b9723e9619 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 @@ error: 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);