* [PATCH v2] librte_pmd_bond: remove memory alloc for rte_pci_driver @ 2015-03-23 21:53 Jia Yu [not found] ` <1427147636-45003-1-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Jia Yu @ 2015-03-23 21:53 UTC (permalink / raw) To: dev-VfR2kkLFssw 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 <jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> --- 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) -- 1.9.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1427147636-45003-1-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH v2] librte_pmd_bond: remove memory alloc for rte_pci_driver [not found] ` <1427147636-45003-1-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> @ 2015-03-26 11:59 ` Declan Doherty [not found] ` <5513F486.4040906-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Declan Doherty @ 2015-03-26 11:59 UTC (permalink / raw) To: Jia Yu, dev-VfR2kkLFssw 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 <jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> > --- > 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 <declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <5513F486.4040906-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2] librte_pmd_bond: remove memory alloc for rte_pci_driver [not found] ` <5513F486.4040906-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2015-03-27 11:03 ` Thomas Monjalon 0 siblings, 0 replies; 3+ messages in thread From: Thomas Monjalon @ 2015-03-27 11:03 UTC (permalink / raw) To: Jia Yu; +Cc: dev-VfR2kkLFssw > > 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 <jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> > > Acked-by: Declan Doherty <declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> Applied, thanks ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-27 11:03 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-03-23 21:53 [PATCH v2] librte_pmd_bond: remove memory alloc for rte_pci_driver Jia Yu [not found] ` <1427147636-45003-1-git-send-email-jyu-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org> 2015-03-26 11:59 ` Declan Doherty [not found] ` <5513F486.4040906-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2015-03-27 11:03 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).