From patchwork Wed Sep 12 01:31:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ziye Yang X-Patchwork-Id: 44605 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A445C326D; Wed, 12 Sep 2018 03:33:06 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id B625F2BFA for ; Wed, 12 Sep 2018 03:33:04 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2018 18:33:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,362,1531810800"; d="scan'208";a="73519587" Received: from ziyeyang-mobl.ccr.corp.intel.com (HELO localhost.localdomain.localdomain) ([10.67.64.89]) by orsmga006.jf.intel.com with ESMTP; 11 Sep 2018 18:31:52 -0700 From: Ziye Yang To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, Ziye Yang Date: Wed, 12 Sep 2018 09:31:50 +0800 Message-Id: <1536715910-38320-1-git-send-email-ziye.yang@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1536125954-46632-1-git-send-email-ziye.yang@intel.com> References: <1536125954-46632-1-git-send-email-ziye.yang@intel.com> Subject: [dpdk-dev] [PATCH v8] linuxapp, eal: Fix the memory leak issue of logid X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ziye Yang This patch is used to fix the memory leak issue of logid. We use the ASAN test in SPDK when intergrating DPDK and find this memory leak issue. Signed-off-by: Ziye Yang Reviewed-by: Ferruh Yigit --- lib/librte_eal/linuxapp/eal/eal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index e59ac65..46494f9 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -793,7 +793,8 @@ static void rte_eal_init_alert(const char *msg) 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]; @@ -810,9 +811,8 @@ static void rte_eal_init_alert(const char *msg) return -1; } - logid = strrchr(argv[0], '/'); - logid = strdup(logid ? logid + 1: argv[0]); - + p = strrchr(argv[0], '/'); + snprintf(logid, sizeof(logid), "%s", (p ? p + 1 : argv[0])); thread_id = pthread_self(); eal_reset_internal_config(&internal_config);