From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH] memzone: Check socket_id value when creating memzone. Date: Fri, 12 May 2017 09:42:20 +0100 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 Cc: dev@dpdk.org To: Tonghao Zhang 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) Content-Disposition: inline In-Reply-To: <1494569023-7564-1-git-send-email-nic@opencloud.tech> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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