From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 69B89567F for ; Fri, 12 May 2017 10:42:24 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2017 01:42:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,328,1491289200"; d="scan'208";a="1168176905" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.42]) by fmsmga002.fm.intel.com with SMTP; 12 May 2017 01:42:21 -0700 Received: by (sSMTP sendmail emulation); Fri, 12 May 2017 09:42:21 +0100 Date: Fri, 12 May 2017 09:42:20 +0100 From: Bruce Richardson To: Tonghao Zhang Cc: dev@dpdk.org Message-ID: <20170512084220.GB53020@bricha3-MOBL3.ger.corp.intel.com> References: <1494569023-7564-1-git-send-email-nic@opencloud.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1494569023-7564-1-git-send-email-nic@opencloud.tech> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.8.0 (2017-02-23) Subject: Re: [dpdk-dev] [PATCH] memzone: Check socket_id value when creating memzone. 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: Fri, 12 May 2017 08:42:24 -0000 On Thu, May 11, 2017 at 11:03:43PM -0700, Tonghao Zhang wrote: > If the socket_id is invalid (e.g. -2, -3), the > memzone_reserve_aligned_thread_unsafe should return the > EINVAL and not ENOMEM. To avoid it, we should check the > socket_id before calling malloc_heap_alloc. > > Signed-off-by: Tonghao Zhang > --- > lib/librte_eal/common/eal_common_memzone.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c > index 64f4e0a..3026e36 100644 > --- a/lib/librte_eal/common/eal_common_memzone.c > +++ b/lib/librte_eal/common/eal_common_memzone.c > @@ -189,7 +189,8 @@ > return NULL; > } > > - if ((socket_id != SOCKET_ID_ANY) && (socket_id >= RTE_MAX_NUMA_NODES)) { > + if ((socket_id != SOCKET_ID_ANY) && > + (socket_id >= RTE_MAX_NUMA_NODES || socket_id < 0)) { > rte_errno = EINVAL; > return NULL; > } > -- Looks a sensible thing to do. Acked-by: Bruce Richardson