DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] crypto: fix memory leak
@ 2016-07-18 12:00 Pablo de Lara
  2016-07-18 12:32 ` Pattan, Reshma
  2016-07-18 12:47 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
  0 siblings, 2 replies; 8+ messages in thread
From: Pablo de Lara @ 2016-07-18 12:00 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, Pablo de Lara

When parsing the parameters for virtual device initialization,
rte_kvargs structure was being freed only if there was an error,
not when parsing was successful.

Coverity issue: 124568

Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_cryptodev/rte_cryptodev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 20e5beb..aaa9879 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -148,7 +148,7 @@ int
 rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
 		const char *input_args)
 {
-	struct rte_kvargs *kvlist;
+	struct rte_kvargs *kvlist = NULL;
 	int ret;
 
 	if (params == NULL)
@@ -187,10 +187,11 @@ rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
 		}
 	}
 
-	return 0;
+	ret = 0;
 
 free_kvlist:
-	rte_kvargs_free(kvlist);
+	if (kvlist != NULL)
+		rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH] crypto: fix memory leak
  2016-07-18 12:00 [dpdk-dev] [PATCH] crypto: fix memory leak Pablo de Lara
@ 2016-07-18 12:32 ` Pattan, Reshma
  2016-07-18 12:42   ` De Lara Guarch, Pablo
  2016-07-18 12:47 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
  1 sibling, 1 reply; 8+ messages in thread
From: Pattan, Reshma @ 2016-07-18 12:32 UTC (permalink / raw)
  To: De Lara Guarch, Pablo; +Cc: Doherty, Declan, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Monday, July 18, 2016 1:01 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev] [PATCH] crypto: fix memory leak
> 
> When parsing the parameters for virtual device initialization, rte_kvargs
> structure was being freed only if there was an error, not when parsing was
> successful.
> 
> Coverity issue: 124568
> 
> Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
> --- a/lib/librte_cryptodev/rte_cryptodev.c
> +++ b/lib/librte_cryptodev/rte_cryptodev.c
> @@ -148,7 +148,7 @@ int
>  	int ret;

You can initialize  ret to 0  here instead of below.

> 
>  	if (params == NULL)
> @@ -187,10 +187,11 @@ rte_cryptodev_parse_vdev_init_params(struct
> rte_crypto_vdev_init_params *params,
>  		}
>  	}
> 
> -	return 0;
> +	ret = 0;

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

* Re: [dpdk-dev] [PATCH] crypto: fix memory leak
  2016-07-18 12:32 ` Pattan, Reshma
@ 2016-07-18 12:42   ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 8+ messages in thread
From: De Lara Guarch, Pablo @ 2016-07-18 12:42 UTC (permalink / raw)
  To: Pattan, Reshma; +Cc: Doherty, Declan, dev



> -----Original Message-----
> From: Pattan, Reshma
> Sent: Monday, July 18, 2016 1:32 PM
> To: De Lara Guarch, Pablo
> Cc: Doherty, Declan; dev@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] crypto: fix memory leak
> 
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> > Sent: Monday, July 18, 2016 1:01 PM
> > To: dev@dpdk.org
> > Cc: Doherty, Declan <declan.doherty@intel.com>; De Lara Guarch, Pablo
> > <pablo.de.lara.guarch@intel.com>
> > Subject: [dpdk-dev] [PATCH] crypto: fix memory leak
> >
> > When parsing the parameters for virtual device initialization, rte_kvargs
> > structure was being freed only if there was an error, not when parsing was
> > successful.
> >
> > Coverity issue: 124568
> >
> > Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > ---
> > --- a/lib/librte_cryptodev/rte_cryptodev.c
> > +++ b/lib/librte_cryptodev/rte_cryptodev.c
> > @@ -148,7 +148,7 @@ int
> >  	int ret;
> 
> You can initialize  ret to 0  here instead of below.

True. Thanks for this, will send a v2 shortly.

> 
> >
> >  	if (params == NULL)
> > @@ -187,10 +187,11 @@ rte_cryptodev_parse_vdev_init_params(struct
> > rte_crypto_vdev_init_params *params,
> >  		}
> >  	}
> >
> > -	return 0;
> > +	ret = 0;

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

* [dpdk-dev] [PATCH v2] crypto: fix memory leak
  2016-07-18 12:00 [dpdk-dev] [PATCH] crypto: fix memory leak Pablo de Lara
  2016-07-18 12:32 ` Pattan, Reshma
@ 2016-07-18 12:47 ` Pablo de Lara
  2016-07-18 12:59   ` Pattan, Reshma
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Pablo de Lara @ 2016-07-18 12:47 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, reshma.pattan, Pablo de Lara

When parsing the parameters for virtual device initialization,
rte_kvargs structure was being freed only if there was an error,
not when parsing was successful.

Coverity issue: 124568

Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---

Changes in v2:
- Initialize ret variable to 0 (success)

 lib/librte_cryptodev/rte_cryptodev.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 20e5beb..db809d8 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -148,8 +148,8 @@ int
 rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
 		const char *input_args)
 {
-	struct rte_kvargs *kvlist;
-	int ret;
+	struct rte_kvargs *kvlist = NULL;
+	int ret = 0;
 
 	if (params == NULL)
 		return -EINVAL;
@@ -187,10 +187,9 @@ rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
 		}
 	}
 
-	return 0;
-
 free_kvlist:
-	rte_kvargs_free(kvlist);
+	if (kvlist != NULL)
+		rte_kvargs_free(kvlist);
 	return ret;
 }
 
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v2] crypto: fix memory leak
  2016-07-18 12:47 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
@ 2016-07-18 12:59   ` Pattan, Reshma
  2016-07-18 13:00   ` Mcnamara, John
  2016-07-18 13:21   ` [dpdk-dev] [PATCH v3] " Pablo de Lara
  2 siblings, 0 replies; 8+ messages in thread
From: Pattan, Reshma @ 2016-07-18 12:59 UTC (permalink / raw)
  To: De Lara Guarch, Pablo; +Cc: Doherty, Declan, dev



> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Monday, July 18, 2016 1:47 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; Pattan, Reshma
> <reshma.pattan@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [PATCH v2] crypto: fix memory leak
> 
> When parsing the parameters for virtual device initialization, rte_kvargs
> structure was being freed only if there was an error, not when parsing was
> successful.
> 
> Coverity issue: 124568
> 
> Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Acked-by: Reshma Pattan <reshma.pattan@intel.com>

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

* Re: [dpdk-dev] [PATCH v2] crypto: fix memory leak
  2016-07-18 12:47 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
  2016-07-18 12:59   ` Pattan, Reshma
@ 2016-07-18 13:00   ` Mcnamara, John
  2016-07-18 13:21   ` [dpdk-dev] [PATCH v3] " Pablo de Lara
  2 siblings, 0 replies; 8+ messages in thread
From: Mcnamara, John @ 2016-07-18 13:00 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev
  Cc: Doherty, Declan, Pattan, Reshma, De Lara Guarch, Pablo



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara
> Sent: Monday, July 18, 2016 1:47 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>; Pattan, Reshma
> <reshma.pattan@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev] [PATCH v2] crypto: fix memory leak
>
> ...
>
>  free_kvlist:
> -	rte_kvargs_free(kvlist);
> +	if (kvlist != NULL)
> +		rte_kvargs_free(kvlist);
>  	return ret;

The test against NULL isn't required, that is done in rte_kvargs_free() anyway.

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

* [dpdk-dev] [PATCH v3] crypto: fix memory leak
  2016-07-18 12:47 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
  2016-07-18 12:59   ` Pattan, Reshma
  2016-07-18 13:00   ` Mcnamara, John
@ 2016-07-18 13:21   ` Pablo de Lara
  2016-07-22  9:02     ` Thomas Monjalon
  2 siblings, 1 reply; 8+ messages in thread
From: Pablo de Lara @ 2016-07-18 13:21 UTC (permalink / raw)
  To: dev; +Cc: declan.doherty, reshma.pattan, john.nmcnamara, Pablo de Lara

When parsing the parameters for virtual device initialization,
rte_kvargs structure was being freed only if there was an error,
not when parsing was successful.

Coverity issue: 124568

Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Reshma Pattan <reshma.pattan@intel.com>
---

Changes in v3:
- Removed unnecessary NULL check

Changes in v2:
- Initialized ret variable to 0 (success)

 lib/librte_cryptodev/rte_cryptodev.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 20e5beb..fc4123b 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -148,8 +148,8 @@ int
 rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
 		const char *input_args)
 {
-	struct rte_kvargs *kvlist;
-	int ret;
+	struct rte_kvargs *kvlist = NULL;
+	int ret = 0;
 
 	if (params == NULL)
 		return -EINVAL;
@@ -187,8 +187,6 @@ rte_cryptodev_parse_vdev_init_params(struct rte_crypto_vdev_init_params *params,
 		}
 	}
 
-	return 0;
-
 free_kvlist:
 	rte_kvargs_free(kvlist);
 	return ret;
-- 
2.7.4

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

* Re: [dpdk-dev] [PATCH v3] crypto: fix memory leak
  2016-07-18 13:21   ` [dpdk-dev] [PATCH v3] " Pablo de Lara
@ 2016-07-22  9:02     ` Thomas Monjalon
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2016-07-22  9:02 UTC (permalink / raw)
  To: Pablo de Lara; +Cc: dev, declan.doherty, reshma.pattan, john.nmcnamara

2016-07-18 14:21, Pablo de Lara:
> When parsing the parameters for virtual device initialization,
> rte_kvargs structure was being freed only if there was an error,
> not when parsing was successful.
> 
> Coverity issue: 124568
> 
> Fixes: f3e764fa2fb7 ("cryptodev: uninline parameter parsing")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> Acked-by: Reshma Pattan <reshma.pattan@intel.com>

Applied, thanks

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

end of thread, other threads:[~2016-07-22  9:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 12:00 [dpdk-dev] [PATCH] crypto: fix memory leak Pablo de Lara
2016-07-18 12:32 ` Pattan, Reshma
2016-07-18 12:42   ` De Lara Guarch, Pablo
2016-07-18 12:47 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
2016-07-18 12:59   ` Pattan, Reshma
2016-07-18 13:00   ` Mcnamara, John
2016-07-18 13:21   ` [dpdk-dev] [PATCH v3] " Pablo de Lara
2016-07-22  9:02     ` 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).