From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C9B8A0548; Tue, 27 Apr 2021 11:36:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E18A74067E; Tue, 27 Apr 2021 11:36:31 +0200 (CEST) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id AE79F40150 for ; Tue, 27 Apr 2021 11:36:30 +0200 (CEST) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FTxQS4WmWzPsFY; Tue, 27 Apr 2021 17:33:20 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Tue, 27 Apr 2021 17:36:22 +0800 From: "Min Hu (Connor)" To: CC: , , , , Date: Tue, 27 Apr 2021 17:36:32 +0800 Message-ID: <1619516192-40499-1-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] lib: fix socket id type X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Chengchang Tang The variable type of the current socket ID is uint8_t. When traversing all nodes, the socket ID is compared with RTE_MAX_NUMA_NODES. Since RTE_MAX_NUMA_NODES has not been verified, it may be larger than UCHAR_MAX theoretically. This would lead to an infinite loop. This patch declares the socket ID type as 'int' or 'unsigned int' by referring to the common practice in EAL. Fixes: 56b6ef874f80 ("efd: new Elastic Flow Distributor library") Fixes: f00708c2aa53 ("node: add IPv4 rewrite and lookup control") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Min Hu (Connor) --- lib/efd/rte_efd.c | 4 ++-- lib/node/ip4_lookup.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c index 77f4680..4d354d8 100644 --- a/lib/efd/rte_efd.c +++ b/lib/efd/rte_efd.c @@ -500,7 +500,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, struct rte_efd_table *table = NULL; uint8_t *key_array = NULL; uint32_t num_chunks, num_chunks_shift; - uint8_t socket_id; + unsigned int socket_id; struct rte_efd_list *efd_list = NULL; struct rte_tailq_entry *te; uint64_t offline_table_size; @@ -746,7 +746,7 @@ rte_efd_find_existing(const char *name) void rte_efd_free(struct rte_efd_table *table) { - uint8_t socket_id; + unsigned int socket_id; struct rte_efd_list *efd_list; struct rte_tailq_entry *te, *temp; diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c index d083a72..4811378 100644 --- a/lib/node/ip4_lookup.c +++ b/lib/node/ip4_lookup.c @@ -129,7 +129,7 @@ rte_node_ip4_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop, { char abuf[INET6_ADDRSTRLEN]; struct in_addr in; - uint8_t socket; + int socket; uint32_t val; int ret; -- 2.7.4