From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by dpdk.org (Postfix) with ESMTP id B8C8E2952 for ; Fri, 12 May 2017 08:04:05 +0200 (CEST) X-QQ-mid: bizesmtp7t1494569039tm578gnvd Received: from local.opencloud.tech.localdomai (unknown [106.120.127.10]) by esmtp4.qq.com (ESMTP) with id ; Fri, 12 May 2017 14:03:52 +0800 (CST) X-QQ-SSF: 01100000000000F0FG80 X-QQ-FEAT: 6dXuswn9i1VztXJ6ZIZKAiSXX4qvk6AtAAZV44mCrzjTlM/4zg0LGO3GAhnFx 4Cq059q44P1QaMkO7PtbRHJLVwykYjLYwaYFBsiBCAges1IQGRgLp2nEsAdA7NYh5xxSHsE zY8T7OVVkpt1ZtV91p36lnD9j8Og1OewLurGXDx51fuvzgwyyqc3tz4Ieezi1DAjlqu6EFF w2hovsS4saOmRnpUK6EVqg6RBcWzdbQtRq9bhufYeC3Pdo/MPigCQN9FxeNcrY7CCgEwnGV 8hKA== X-QQ-GoodBg: 0 From: Tonghao Zhang To: dev@dpdk.org Cc: Tonghao Zhang Date: Thu, 11 May 2017 23:03:43 -0700 Message-Id: <1494569023-7564-1-git-send-email-nic@opencloud.tech> X-Mailer: git-send-email 1.8.3.1 X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Subject: [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 06:04:07 -0000 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; } -- 1.8.3.1