summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZiye Yang <ziye.yang@intel.com>2018-09-12 09:31:50 +0800
committerThomas Monjalon <thomas@monjalon.net>2018-10-28 11:42:18 +0100
commite4f2c1421d8036a4778c43bf25201ef5fb37ad6f (patch)
tree497f6a881a1f9706dd7f399b18d6ab7df6664a88 /lib
parent8721e07478c6edc9565645047742f79c654cfd1b (diff)
downloaddpdk-e4f2c1421d8036a4778c43bf25201ef5fb37ad6f.zip
dpdk-e4f2c1421d8036a4778c43bf25201ef5fb37ad6f.tar.gz
dpdk-e4f2c1421d8036a4778c43bf25201ef5fb37ad6f.tar.xz
eal/linux: fix memory leak of logid
This patch is used to fix the memory leak issue of logid. We use the ASAN test in SPDK when integrating DPDK and find this memory leak issue. Fixes: d8a2bc71dfc2 ("log: remove app path from syslog id") Cc: stable@dpdk.org Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_eal/linuxapp/eal/eal.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 7b11375..67116ee 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -825,7 +825,8 @@ rte_eal_init(int argc, char **argv)
int i, fctret, ret;
pthread_t thread_id;
static rte_atomic32_t run_once = RTE_ATOMIC32_INIT(0);
- const char *logid;
+ const char *p;
+ static char logid[PATH_MAX];
char cpuset[RTE_CPU_AFFINITY_STR_LEN];
char thread_name[RTE_MAX_THREAD_NAME_LEN];
@@ -842,9 +843,8 @@ rte_eal_init(int argc, char **argv)
return -1;
}
- logid = strrchr(argv[0], '/');
- logid = strdup(logid ? logid + 1: argv[0]);
-
+ p = strrchr(argv[0], '/');
+ strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));
thread_id = pthread_self();
eal_reset_internal_config(&internal_config);