DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit()
@ 2015-11-18 22:29 Mauricio Vasquez B
  2015-11-20 12:20 ` Iremonger, Bernard
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mauricio Vasquez B @ 2015-11-18 22:29 UTC (permalink / raw)
  To: dev

When freeing the device, it is also necessary to free rx_queues and tx_queues

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
---
 drivers/net/ring/rte_eth_ring.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 9a31bce..e091e4f 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -582,6 +582,9 @@ rte_pmd_ring_devuninit(const char *name)
 		return -ENODEV;
 
 	eth_dev_stop(eth_dev);
+
+	rte_free(eth_dev->data->rx_queues);
+	rte_free(eth_dev->data->tx_queues);
 	rte_free(eth_dev->data->dev_private);
 	rte_free(eth_dev->data);
 
-- 
1.9.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit()
  2015-11-18 22:29 [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit() Mauricio Vasquez B
@ 2015-11-20 12:20 ` Iremonger, Bernard
  2015-11-20 12:32 ` Mcnamara, John
  2015-11-20 18:24 ` [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit Mauricio Vasquez B
  2 siblings, 0 replies; 7+ messages in thread
From: Iremonger, Bernard @ 2015-11-20 12:20 UTC (permalink / raw)
  To: Mauricio Vasquez B, dev

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mauricio Vasquez B
> Sent: Wednesday, November 18, 2015 10:29 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] ring: Fix memory leakage in
> rte_pmd_ring_devuninit()
> 
> When freeing the device, it is also necessary to free rx_queues and
> tx_queues
> 
> Signed-off-by: Mauricio Vasquez B
> <mauricio.vasquezbernal@studenti.polito.it>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit()
  2015-11-18 22:29 [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit() Mauricio Vasquez B
  2015-11-20 12:20 ` Iremonger, Bernard
@ 2015-11-20 12:32 ` Mcnamara, John
  2015-11-20 12:42   ` Richardson, Bruce
  2015-11-20 18:24 ` [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit Mauricio Vasquez B
  2 siblings, 1 reply; 7+ messages in thread
From: Mcnamara, John @ 2015-11-20 12:32 UTC (permalink / raw)
  To: Mauricio Vasquez B, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mauricio Vasquez B
> Sent: Wednesday, November 18, 2015 10:29 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] ring: Fix memory leakage in
> rte_pmd_ring_devuninit()
> 
> When freeing the device, it is also necessary to free rx_queues and
> tx_queues
> 
> Signed-off-by: Mauricio Vasquez B
> <mauricio.vasquezbernal@studenti.polito.it>
> ---
>  drivers/net/ring/rte_eth_ring.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ring/rte_eth_ring.c
> b/drivers/net/ring/rte_eth_ring.c index 9a31bce..e091e4f 100644
> --- a/drivers/net/ring/rte_eth_ring.c
> +++ b/drivers/net/ring/rte_eth_ring.c
> @@ -582,6 +582,9 @@ rte_pmd_ring_devuninit(const char *name)
>  		return -ENODEV;
> 
>  	eth_dev_stop(eth_dev);
> +
> +	rte_free(eth_dev->data->rx_queues);
> +	rte_free(eth_dev->data->tx_queues);
>  	rte_free(eth_dev->data->dev_private);
>  	rte_free(eth_dev->data);

Hi,

This should test for eth_dev->data before freeing the members. Like:

    if (eth_dev->data) {
        rte_free(eth_dev->data->rx_queues);
        rte_free(eth_dev->data->tx_queues);
        rte_free(eth_dev->data->dev_private);
    }

Thanks,

John

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit()
  2015-11-20 12:32 ` Mcnamara, John
@ 2015-11-20 12:42   ` Richardson, Bruce
  2015-11-20 18:22     ` Mauricio Vásquez
  0 siblings, 1 reply; 7+ messages in thread
From: Richardson, Bruce @ 2015-11-20 12:42 UTC (permalink / raw)
  To: Mcnamara, John, Mauricio Vasquez B, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mcnamara, John
> Sent: Friday, November 20, 2015 12:32 PM
> To: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>;
> dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in
> rte_pmd_ring_devuninit()
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mauricio Vasquez
> > B
> > Sent: Wednesday, November 18, 2015 10:29 PM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH] ring: Fix memory leakage in
> > rte_pmd_ring_devuninit()
> >
> > When freeing the device, it is also necessary to free rx_queues and
> > tx_queues
> >
> > Signed-off-by: Mauricio Vasquez B
> > <mauricio.vasquezbernal@studenti.polito.it>
> > ---
> >  drivers/net/ring/rte_eth_ring.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/ring/rte_eth_ring.c
> > b/drivers/net/ring/rte_eth_ring.c index 9a31bce..e091e4f 100644
> > --- a/drivers/net/ring/rte_eth_ring.c
> > +++ b/drivers/net/ring/rte_eth_ring.c
> > @@ -582,6 +582,9 @@ rte_pmd_ring_devuninit(const char *name)
> >  		return -ENODEV;
> >
> >  	eth_dev_stop(eth_dev);
> > +
> > +	rte_free(eth_dev->data->rx_queues);
> > +	rte_free(eth_dev->data->tx_queues);
> >  	rte_free(eth_dev->data->dev_private);
> >  	rte_free(eth_dev->data);
> 
> Hi,
> 
> This should test for eth_dev->data before freeing the members. Like:
> 
>     if (eth_dev->data) {
>         rte_free(eth_dev->data->rx_queues);
>         rte_free(eth_dev->data->tx_queues);
>         rte_free(eth_dev->data->dev_private);
>     }
> 
> Thanks,
> 
> John

That was my thought initially too, but since this is an uninit routine, the data field must already have been set up correctly by the init/creation function. 
That being said, the check does no harm, so we might as well add it.

/Bruce

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit()
  2015-11-20 12:42   ` Richardson, Bruce
@ 2015-11-20 18:22     ` Mauricio Vásquez
  0 siblings, 0 replies; 7+ messages in thread
From: Mauricio Vásquez @ 2015-11-20 18:22 UTC (permalink / raw)
  To: Richardson, Bruce; +Cc: dev

On 20 November 2015 at 13:42, Richardson, Bruce <bruce.richardson@intel.com>
wrote:

>
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mcnamara, John
> > Sent: Friday, November 20, 2015 12:32 PM
> > To: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>;
> > dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in
> > rte_pmd_ring_devuninit()
> >
> >
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mauricio Vasquez
> > > B
> > > Sent: Wednesday, November 18, 2015 10:29 PM
> > > To: dev@dpdk.org
> > > Subject: [dpdk-dev] [PATCH] ring: Fix memory leakage in
> > > rte_pmd_ring_devuninit()
> > >
> > > When freeing the device, it is also necessary to free rx_queues and
> > > tx_queues
> > >
> > > Signed-off-by: Mauricio Vasquez B
> > > <mauricio.vasquezbernal@studenti.polito.it>
> > > ---
> > >  drivers/net/ring/rte_eth_ring.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/drivers/net/ring/rte_eth_ring.c
> > > b/drivers/net/ring/rte_eth_ring.c index 9a31bce..e091e4f 100644
> > > --- a/drivers/net/ring/rte_eth_ring.c
> > > +++ b/drivers/net/ring/rte_eth_ring.c
> > > @@ -582,6 +582,9 @@ rte_pmd_ring_devuninit(const char *name)
> > >             return -ENODEV;
> > >
> > >     eth_dev_stop(eth_dev);
> > > +
> > > +   rte_free(eth_dev->data->rx_queues);
> > > +   rte_free(eth_dev->data->tx_queues);
> > >     rte_free(eth_dev->data->dev_private);
> > >     rte_free(eth_dev->data);
> >
> > Hi,
> >
> > This should test for eth_dev->data before freeing the members. Like:
> >
> >     if (eth_dev->data) {
> >         rte_free(eth_dev->data->rx_queues);
> >         rte_free(eth_dev->data->tx_queues);
> >         rte_free(eth_dev->data->dev_private);
> >     }
> >
> > Thanks,
> >
> > John
>
> That was my thought initially too, but since this is an uninit routine,
> the data field must already have been set up correctly by the init/creation
> function.
>
That was my reasoning too.

> That being said, the check does no harm, so we might as well add it.
>
I agree, I will send a new patch version.

>
> /Bruce
>

Mauricio V,

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit
  2015-11-18 22:29 [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit() Mauricio Vasquez B
  2015-11-20 12:20 ` Iremonger, Bernard
  2015-11-20 12:32 ` Mcnamara, John
@ 2015-11-20 18:24 ` Mauricio Vasquez B
  2015-11-23 22:47   ` Thomas Monjalon
  2 siblings, 1 reply; 7+ messages in thread
From: Mauricio Vasquez B @ 2015-11-20 18:24 UTC (permalink / raw)
  To: dev

When freeing the device it is also neccesary to free
rx_queues and tx_queues

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
---
v2:
Added extra control before freeing members of eth_dev->data

 drivers/net/ring/rte_eth_ring.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 9a31bce..4ce0256 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -582,7 +582,12 @@ rte_pmd_ring_devuninit(const char *name)
 		return -ENODEV;
 
 	eth_dev_stop(eth_dev);
-	rte_free(eth_dev->data->dev_private);
+
+	if(eth_dev->data) {
+		rte_free(eth_dev->data->rx_queues);
+		rte_free(eth_dev->data->tx_queues);
+		rte_free(eth_dev->data->dev_private);
+	}
 	rte_free(eth_dev->data);
 
 	rte_eth_dev_release_port(eth_dev);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit
  2015-11-20 18:24 ` [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit Mauricio Vasquez B
@ 2015-11-23 22:47   ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2015-11-23 22:47 UTC (permalink / raw)
  To: Mauricio Vasquez B; +Cc: dev

2015-11-20 19:24, Mauricio Vasquez B:
> When freeing the device it is also neccesary to free
> rx_queues and tx_queues
> 
> Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>

Applied with spacing fix, thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-23 22:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-18 22:29 [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit() Mauricio Vasquez B
2015-11-20 12:20 ` Iremonger, Bernard
2015-11-20 12:32 ` Mcnamara, John
2015-11-20 12:42   ` Richardson, Bruce
2015-11-20 18:22     ` Mauricio Vásquez
2015-11-20 18:24 ` [dpdk-dev] [PATCH] ring: Fix memory leakage in rte_pmd_ring_devuninit Mauricio Vasquez B
2015-11-23 22:47   ` 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).