From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 557FD4C74 for ; Tue, 11 Sep 2018 12:09:52 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2018 03:09:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,360,1531810800"; d="scan'208";a="79556307" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by FMSMGA003.fm.intel.com with ESMTP; 11 Sep 2018 03:09:40 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.54]) by IRSMSX106.ger.corp.intel.com ([169.254.8.41]) with mapi id 14.03.0319.002; Tue, 11 Sep 2018 11:09:40 +0100 From: "Ananyev, Konstantin" To: "Yang, Ziye" , "dev@dpdk.org" CC: Ziye Yang Thread-Topic: [PATCH v7] linuxapp, eal: Fix the memory leak issue of logid Thread-Index: AQHUSW63Vl+t8NxLS0eE4RIgpVsd6KTq2+8g Date: Tue, 11 Sep 2018 10:09:39 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258EA954037@irsmsx105.ger.corp.intel.com> References: <1536125954-46632-1-git-send-email-ziye.yang@intel.com> <1536629269-35295-1-git-send-email-ziye.yang@intel.com> In-Reply-To: <1536629269-35295-1-git-send-email-ziye.yang@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWMzYWU5ZGItMzA4Ni00MDRjLWE4OTktYWM3NmUyMzBkOWYyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMTM3TmNFT05LZXVVQXhrK1lGUHZxK2Q2VVB6d210UWppRloxRzhRVEpwYytZSFFMUmJcL1pqMDFXN0xwUXdoMXMifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v7] 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: , X-List-Received-Date: Tue, 11 Sep 2018 10:09:53 -0000 > -----Original Message----- > From: Yang, Ziye > Sent: Tuesday, September 11, 2018 2:28 AM > To: dev@dpdk.org > Cc: Ananyev, Konstantin ; Ziye Yang > Subject: [PATCH v7] linuxapp, eal: Fix the memory leak issue of logid >=20 > From: Ziye Yang >=20 > 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. >=20 > By the way, we also fix several missed function call of > rte_atomic32_clear. >=20 > Signed-off-by: Ziye Yang > --- > lib/librte_eal/linuxapp/eal/eal.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/= eal/eal.c > index e59ac65..a5129e5 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 =3D 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]; >=20 > @@ -810,9 +811,8 @@ static void rte_eal_init_alert(const char *msg) > return -1; > } >=20 > - logid =3D strrchr(argv[0], '/'); > - logid =3D strdup(logid ? logid + 1: argv[0]); > - > + p =3D strrchr(argv[0], '/'); > + snprintf(logid, sizeof(logid), "%s", (p ? p + 1 : argv[0])); > thread_id =3D pthread_self(); >=20 > eal_reset_internal_config(&internal_config); > @@ -823,6 +823,7 @@ static void rte_eal_init_alert(const char *msg) > if (rte_eal_cpu_init() < 0) { > rte_eal_init_alert("Cannot detect lcores."); > rte_errno =3D ENOTSUP; > + rte_atomic32_clear(&run_once); > return -1; > } >=20 > @@ -851,6 +852,7 @@ static void rte_eal_init_alert(const char *msg) >=20 > if (rte_eal_intr_init() < 0) { > rte_eal_init_alert("Cannot init interrupt-handling thread\n"); > + rte_atomic32_clear(&run_once); > return -1; > } >=20 > @@ -861,6 +863,7 @@ static void rte_eal_init_alert(const char *msg) > rte_eal_init_alert("failed to init mp channel\n"); > if (rte_eal_process_type() =3D=3D RTE_PROC_PRIMARY) { > rte_errno =3D EFAULT; > + rte_atomic32_clear(&run_once); > return -1; > } > } > -- Acked-by: Konstantin Ananyev > 1.9.3