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 C55A8A0351; Mon, 10 Jan 2022 10:23:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F38C41C26; Mon, 10 Jan 2022 10:23:11 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 5493A4013F; Mon, 10 Jan 2022 10:23:09 +0100 (CET) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4JXSyJ56WLz9s8f; Mon, 10 Jan 2022 17:22:00 +0800 (CST) Received: from dggpemm500008.china.huawei.com (7.185.36.136) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 10 Jan 2022 17:23:07 +0800 Received: from localhost (10.174.242.157) by dggpemm500008.china.huawei.com (7.185.36.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 10 Jan 2022 17:23:06 +0800 From: Yunjian Wang To: CC: , , , , Yunjian Wang , Subject: [dpdk-dev] [PATCH] ring: fix error return value when creating ring Date: Mon, 10 Jan 2022 17:23:03 +0800 Message-ID: <6d7c9da7eb47cb236710a870d91219f1c3ca4684.1641785123.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.242.157] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500008.china.huawei.com (7.185.36.136) X-CFilter-Loop: Reflected 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 The error value returned by rte_ring_create_elem() should be positive integers. However, if the rte_ring_get_memsize_elem() function fails, a negative number is returned and is directly used as the return value. As a result, this will cause the external call to check the return value to fail(like called by rte_mempool_create()). Fixes: a182620042aa ("ring: get size in memory") Cc: stable@dpdk.org Reported-by: Nan Zhou Signed-off-by: Yunjian Wang --- lib/ring/rte_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index f17bd966be..185f9be798 100644 --- a/lib/ring/rte_ring.c +++ b/lib/ring/rte_ring.c @@ -267,7 +267,7 @@ rte_ring_create_elem(const char *name, unsigned int esize, unsigned int count, ring_size = rte_ring_get_memsize_elem(esize, count); if (ring_size < 0) { - rte_errno = ring_size; + rte_errno = -ring_size; return NULL; } -- 2.27.0