From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 0FD2B1396 for ; Thu, 26 Mar 2015 12:54:54 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 26 Mar 2015 04:54:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,471,1422950400"; d="scan'208";a="670917044" Received: from dwdohert-dpdk-fedora-20.ir.intel.com ([163.33.213.98]) by orsmga001.jf.intel.com with ESMTP; 26 Mar 2015 04:54:52 -0700 Message-ID: <5513F486.4040906@intel.com> Date: Thu, 26 Mar 2015 11:59:02 +0000 From: Declan Doherty User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Jia Yu , dev@dpdk.org References: <1427147636-45003-1-git-send-email-jyu@vmware.com> In-Reply-To: <1427147636-45003-1-git-send-email-jyu@vmware.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] librte_pmd_bond: remove memory alloc for rte_pci_driver 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: Thu, 26 Mar 2015 11:54:55 -0000 On 23/03/15 21:53, Jia Yu wrote: > eth_driver already contains rte_pci_driver data structure. > Allocating rte_pci_driver without referencing it after bond > creation causes memory leakage. > > Added signed off information. > > Signed-off-by: Jia Yu > --- > lib/librte_pmd_bond/rte_eth_bond_api.c | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c > index 903b7c3..13f3941 100644 > --- a/lib/librte_pmd_bond/rte_eth_bond_api.c > +++ b/lib/librte_pmd_bond/rte_eth_bond_api.c > @@ -230,11 +230,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) > goto err; > } > > - pci_drv = rte_zmalloc_socket(name, sizeof(*pci_drv), 0, socket_id); > - if (pci_drv == NULL) { > - RTE_BOND_LOG(ERR, "Unable to malloc pci_drv on socket"); > - goto err; > - } > + pci_drv = ð_drv->pci_drv; > + > pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id); > if (pci_id_table == NULL) { > RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket"); > @@ -266,9 +263,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) > pci_dev->numa_node = socket_id; > pci_drv->name = driver_name; > > - eth_drv->pci_drv = (struct rte_pci_driver)(*pci_drv); > eth_dev->driver = eth_drv; > - > eth_dev->data->dev_private = internals; > eth_dev->data->nb_rx_queues = (uint16_t)1; > eth_dev->data->nb_tx_queues = (uint16_t)1; > @@ -325,8 +320,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) > err: > if (pci_dev) > rte_free(pci_dev); > - if (pci_drv) > - rte_free(pci_drv); > if (pci_id_table) > rte_free(pci_id_table); > if (eth_drv) > Acked-by: Declan Doherty