[dpdk-dev,v3] eal: fix resource leak

Message ID 20171011115353.40043-1-danielx.t.mrzyglod@intel.com (mailing list archive)
State Rejected, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Daniel Mrzyglod Oct. 11, 2017, 11:53 a.m. UTC
  Memory allocated in strdup is not free.

Coverity issue: 143257
Fixes: d8a2bc71dfc2 ("log: remove app path from syslog id")
Cc: thomas@monjalon.net
Cc: stable@dpdk.org

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
v3: 
* remove strdup because it's basically striped argv[0]
v2:
* Fix due to compilation errors
 
 lib/librte_eal/linuxapp/eal/eal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Oct. 11, 2017, 12:43 p.m. UTC | #1
11/10/2017 13:53, Daniel Mrzyglod:
> Memory allocated in strdup is not free.
> 
> Coverity issue: 143257
> Fixes: d8a2bc71dfc2 ("log: remove app path from syslog id")
> Cc: thomas@monjalon.net
> Cc: stable@dpdk.org
> 
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>

Given this recent commit:
	http://dpdk.org/commit/e3f141879ef
I think we should consider this issue as a false positive.

The arguments given to rte_eal_init may be freed.
So it's better to strdup them, even if it is never freed.
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 1f07347..739b61a 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -763,7 +763,7 @@  rte_eal_init(int argc, char **argv)
 	}
 
 	logid = strrchr(argv[0], '/');
-	logid = strdup(logid ? logid + 1: argv[0]);
+	logid = logid ? logid + 1 : argv[0];
 
 	thread_id = pthread_self();