From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 6FACE2A1A for ; Fri, 19 Dec 2014 16:03:36 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 19 Dec 2014 07:01:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,607,1413270000"; d="scan'208";a="657134943" Received: from unknown ([10.217.248.146]) by orsmga002.jf.intel.com with SMTP; 19 Dec 2014 07:02:43 -0800 Received: by (sSMTP sendmail emulation); Fri, 19 Dec 2014 16:01:39 +0200 From: Daniel Mrzyglod To: dev@dpdk.org Date: Fri, 19 Dec 2014 16:01:36 +0100 Message-Id: <1419001296-8300-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.1.1 Subject: [dpdk-dev] [PATCH] af_packet: fix possible memory leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Dec 2014 15:03:36 -0000 In rte_pmd_init_internals, we are mapping memory but not released if error occure it could produce memoryleak. Add unmmap function to release memory. Signed-off-by: Daniel Mrzyglod --- lib/librte_pmd_af_packet/rte_eth_af_packet.c | 7 +++++++ 1 file changed, 7 insertions(+) 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 236749b..93e6b6b 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) -- 2.1.0