From: Daniel Mrzyglod Date: Fri, 19 Dec 2014 15:01:36 +0000 (+0100) Subject: af_packet: fix possible memory leak X-Git-Tag: spdx-start~9893 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dd6590fe2fd7b08be2e31dd8549ed43f7e5435f2;p=dpdk.git af_packet: fix possible memory leak In rte_pmd_init_internals, we are mapping memory but not released if error occurs it could produce memory leak. Add unmmap function to release memory. Signed-off-by: Daniel Mrzyglod Acked-by: Michal Jastrzebski Acked-by: John W. Linville --- diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c index 236749b988..755780a10a 100644 --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c @@ -481,6 +481,11 @@ rte_pmd_init_internals(const char *name, if (*internals == NULL) goto error; + for (q = 0; q < nb_queues; q++) { + (*internals)->rx_queue[q].map = MAP_FAILED; + (*internals)->tx_queue[q].map = MAP_FAILED; + } + req = &((*internals)->req); req->tp_block_size = blocksize; @@ -682,6 +687,8 @@ error: rte_free(pci_dev); if (*internals) { 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].rd) rte_free((*internals)->rx_queue[q].rd); if ((*internals)->tx_queue[q].rd)