From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 0D3AF47D0 for ; Thu, 21 Jul 2016 15:44:49 +0200 (CEST) Received: from alille-653-1-293-182.w90-1.abo.wanadoo.fr ([90.1.53.182] helo=[192.168.1.13]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bQEJs-0007dZ-Sz; Thu, 21 Jul 2016 15:47:25 +0200 To: Zoltan Kiss , dev@dpdk.org References: <1469034999-2732-2-git-send-email-zoltan.kiss@schaman.hu> From: Olivier Matz Message-ID: <5386abeb-0310-a12a-5550-ab6054e9a8e0@6wind.com> Date: Thu, 21 Jul 2016 15:44:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <1469034999-2732-2-git-send-email-zoltan.kiss@schaman.hu> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] memzone: allow full length name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 13:44:49 -0000 Hi, On 07/20/2016 07:16 PM, Zoltan Kiss wrote: > (strlen(name) == sizeof(mz->name) - 1) is a valid case, change the > condition to reflect that. > Move it earlier to avoid lookup with invalid name. > Change errno to ENAMETOOLONG. > > Fixes: 85cf0079 ("mem: avoid memzone/mempool/ring name truncation") > > Signed-off-by: Zoltan Kiss > --- > lib/librte_eal/common/eal_common_memzone.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c > index 5d28341..1bd0a33 100644 > --- a/lib/librte_eal/common/eal_common_memzone.c > +++ b/lib/librte_eal/common/eal_common_memzone.c > @@ -144,6 +144,13 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, > return NULL; > } > > + if (strlen(name) > sizeof(mz->name) - 1) { > + RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n", > + __func__, name); > + rte_errno = ENAMETOOLONG; > + return NULL; > + } > + > /* zone already exist */ > if ((memzone_lookup_thread_unsafe(name)) != NULL) { > RTE_LOG(DEBUG, EAL, "%s(): memzone <%s> already exists\n", > @@ -152,13 +159,6 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, > return NULL; > } > > - if (strlen(name) >= sizeof(mz->name) - 1) { > - RTE_LOG(DEBUG, EAL, "%s(): memzone <%s>: name too long\n", > - __func__, name); > - rte_errno = EEXIST; > - return NULL; > - } > - > /* if alignment is not a power of two */ > if (align && !rte_is_power_of_2(align)) { > RTE_LOG(ERR, EAL, "%s(): Invalid alignment: %u\n", __func__, > Acked-by: Olivier Matz Thanks for fixing this.