Skip to content

Commit

Permalink
ring: fix error code when creating ring
Browse files Browse the repository at this point in the history
[ upstream commit 074717be3ef9e7a8868b5af078b0ca7b61bcc44b ]

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: a182620 ("ring: get size in memory")

Reported-by: Nan Zhou <zhounan14@huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
  • Loading branch information
wyjwang authored and cpaelzer committed Feb 25, 2022
1 parent 685c1a1 commit b737263
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/librte_ring/rte_ring.c
Expand Up @@ -137,7 +137,7 @@ rte_ring_create(const char *name, unsigned count, int socket_id,

ring_size = rte_ring_get_memsize(count);
if (ring_size < 0) {
rte_errno = ring_size;
rte_errno = -ring_size;
return NULL;
}

Expand Down

0 comments on commit b737263

Please sign in to comment.