[dpdk-dev] ring: fix minor memory leak of kvlist in dev init

Message ID 1424697435-13667-1-git-send-email-john.mcnamara@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

John McNamara Feb. 23, 2015, 1:17 p.m. UTC
  Fix for Klockwork identified issue.

Signed-off-by: John McNamara <john.mcnamara@intel.com>
---
 lib/librte_pmd_ring/rte_eth_ring.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
  

Comments

Wodkowski, PawelX Feb. 23, 2015, 1:27 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of John McNamara
> Sent: Monday, February 23, 2015 2:17 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] ring: fix minor memory leak of kvlist in dev init
> 
> Fix for Klockwork identified issue.
> 
> Signed-off-by: John McNamara <john.mcnamara@intel.com>
> ---
>  lib/librte_pmd_ring/rte_eth_ring.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/librte_pmd_ring/rte_eth_ring.c
> b/lib/librte_pmd_ring/rte_eth_ring.c
> index a23e933..88a1382 100644
> --- a/lib/librte_pmd_ring/rte_eth_ring.c
> +++ b/lib/librte_pmd_ring/rte_eth_ring.c
> @@ -527,7 +527,7 @@ out:
>  static int
>  rte_pmd_ring_devinit(const char *name, const char *params)
>  {
> -	struct rte_kvargs *kvlist;
> +	struct rte_kvargs *kvlist = NULL;
>  	int ret = 0;
>  	struct node_action_list *info = NULL;
> 
> @@ -569,6 +569,7 @@ rte_pmd_ring_devinit(const char *name, const char
> *params)
>  out_free:
>  	rte_free(info);
>  out:
> +	rte_kvargs_free(kvlist);
>  	return ret;
>  }
> 
> --
> 1.7.4.1

This is wrong/incomplete as rte_kvargs_free() is unable to handle NULL argument.
I have patch under review that fix this issue along with rte_kvargs_free().

Pawel
  
John McNamara Feb. 24, 2015, 11:39 a.m. UTC | #2
> -----Original Message-----
> From: Mcnamara, John
> Sent: Monday, February 23, 2015 1:17 PM
> To: dev@dpdk.org
> Cc: Mcnamara, John
> Subject: [PATCH] ring: fix minor memory leak of kvlist in dev init
> 
> Fix for Klocwork identified issue.


Superseded by:

   http://dpdk.org/ml/archives/dev/2015-February/013937.html

John
--
  

Patch

diff --git a/lib/librte_pmd_ring/rte_eth_ring.c b/lib/librte_pmd_ring/rte_eth_ring.c
index a23e933..88a1382 100644
--- a/lib/librte_pmd_ring/rte_eth_ring.c
+++ b/lib/librte_pmd_ring/rte_eth_ring.c
@@ -527,7 +527,7 @@  out:
 static int
 rte_pmd_ring_devinit(const char *name, const char *params)
 {
-	struct rte_kvargs *kvlist;
+	struct rte_kvargs *kvlist = NULL;
 	int ret = 0;
 	struct node_action_list *info = NULL;
 
@@ -569,6 +569,7 @@  rte_pmd_ring_devinit(const char *name, const char *params)
 out_free:
 	rte_free(info);
 out:
+	rte_kvargs_free(kvlist);
 	return ret;
 }