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 <danielx.t.mrzyglod@intel.com>
Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
Acked-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Daniel Mrzyglod 2014-12-19 16:01:36 +01:00 committed by Thomas Monjalon
parent 74ab022182
commit dd6590fe2f

View File

@ -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 @@ rte_pmd_init_internals(const char *name,
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)