]> git.droids-corp.org - dpdk.git/commitdiff
ring: fix error code when creating ring
authorYunjian Wang <wangyunjian@huawei.com>
Mon, 10 Jan 2022 09:23:03 +0000 (17:23 +0800)
committerDavid Marchand <david.marchand@redhat.com>
Sat, 5 Feb 2022 16:53:27 +0000 (17:53 +0100)
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 <zhounan14@huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
lib/ring/rte_ring.c

index f17bd966bead123c9140a77aa21746176bb7abfb..185f9be798b6a404de33ed09cda2f43fbffcae63 100644 (file)
@@ -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;
        }