From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 8ADC21B6C2 for ; Wed, 4 Oct 2017 21:24:15 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2017 12:24:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,478,1500966000"; d="scan'208";a="906780544" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.241.225.26]) ([10.241.225.26]) by FMSMGA003.fm.intel.com with ESMTP; 04 Oct 2017 12:24:12 -0700 To: Daniel Mrzyglod , thomas@monjalon.net Cc: dev@dpdk.org References: <20170919133432.6437-1-danielx.t.mrzyglod@intel.com> <20170922144820.16590-1-danielx.t.mrzyglod@intel.com> From: Ferruh Yigit Message-ID: <27670627-01f0-7fff-0aa8-c9a9d2b89e3d@intel.com> Date: Wed, 4 Oct 2017 20:24:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170922144820.16590-1-danielx.t.mrzyglod@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2] eal: fix resource leak 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: , X-List-Received-Date: Wed, 04 Oct 2017 19:24:15 -0000 On 9/22/2017 3:48 PM, Daniel Mrzyglod wrote: > Memory allocated in strdup is not free. > > Coverity issue: 143257 > Fixes: d8a2bc71dfc2 ("log: remove app path from syslog id") > Cc: thomas@monjalon.net > > Signed-off-by: Daniel Mrzyglod > --- > v2: > * Fix due to compilation errors > > lib/librte_eal/linuxapp/eal/eal.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c > index 48f12f4..a7df566 100644 > --- a/lib/librte_eal/linuxapp/eal/eal.c > +++ b/lib/librte_eal/linuxapp/eal/eal.c > @@ -751,7 +751,7 @@ 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; > + char *logid; > char cpuset[RTE_CPU_AFFINITY_STR_LEN]; > char thread_name[RTE_MAX_THREAD_NAME_LEN]; > > @@ -781,6 +781,7 @@ rte_eal_init(int argc, char **argv) > if (rte_eal_cpu_init() < 0) { > rte_eal_init_alert("Cannot detect lcores."); > rte_errno = ENOTSUP; > + free(logid); Hi Daniel, This works but this variable is a nuance and adding free() for this it into main eal features fail path looks like noise. Initially, do we need to strdup this variable at all? What will happen if logid fed into rte_eal_log_init() without strdup? Since it is const char *, I guess the string is just for read and content won't be changed so it should be OK I guess. If above is not right, what about creating a static variable and use it instead of dynamically allocating the logid, what do you think? Thanks, ferruh > return -1; > } > > @@ -789,6 +790,7 @@ rte_eal_init(int argc, char **argv) > rte_eal_init_alert("Invalid 'command line' arguments."); > rte_errno = EINVAL; > rte_atomic32_clear(&run_once); > + free(logid); > return -1; > } > <...>