RDMA/rxe: Return the correct errno
Subsystems (2)
PATCH 1/1 RDMA/rxe: Return the correct errno
In the function __rxe_add_to_pool, the function xa_alloc_cyclic is called. The return value of the function xa_alloc_cyclic is as below:
"
Return: 0 if the allocation succeeded without wrapping. 1 if the allocation succeeded after wrapping, -ENOMEM if memory could not be allocated or -EBUSY if there are no free entries in @limit.
"
But now the function __rxe_add_to_pool only returns -EINVAL. All the returned error value should be returned to the caller.
--- drivers/infiniband/sw/rxe/rxe_pool.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_pool.c +4 -2
@@ -122,8 +122,10 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,int err;gfp_t gfp_flags; -if (atomic_inc_return (&pool->num_elem) > pool->max_elem) +if (atomic_inc_return (&pool->num_elem) > pool->max_elem) { + err = -EINVAL ; goto err_cnt; + } elem->pool = pool; elem->obj = (u8 *)elem - pool->elem_offset;
@@ -147,7 +149,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem, err_cnt:atomic_dec (&pool->num_elem); -return -EINVAL ; +return err; }void *rxe_pool_get_index (struct rxe_pool *pool,u32 index)
Signature · 1 line
2.34.1
Quoted 10 lines · Zhu Yanjun
In the function
__rxe_add_to_pool, the functionxa_alloc_cyclicis called. The return value of the functionxa_alloc_cyclicis as below:
"
Return: 0 if the allocation succeeded without wrapping. 1 if the allocation succeeded after wrapping,-ENOMEMif memory could not be allocated or-EBUSYif there are no free entries in @limit.
"
But now the function__rxe_add_to_poolonly returns-EINVAL. All the returned error value should be returned to the caller.
make sense.
drivers/infiniband/sw/rxe/rxe_pool.c int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem, · line 122
Quoted 11 lines
Signed-off-by Zhu Yanjun <[email protected]>--- drivers/infiniband/sw/rxe/rxe_pool.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/infiniband/sw/rxe/rxe_pool.c +0
-0@@ -122,8 +122,10 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,int err;
I'd like to assign 'err' a default error code: -EINVAL
Thanks
Zhijian
Quoted 19 lines
drivers/infiniband/sw/rxe/rxe_pool.c +4
-2gfp_t gfp_flags; -if (atomic_inc_return (&pool->num_elem) > pool->max_elem) +if (atomic_inc_return (&pool->num_elem) > pool->max_elem) { + err = -EINVAL ; goto err_cnt; + } elem->pool = pool; elem->obj = (u8 *)elem - pool->elem_offset;@@ -147,7 +149,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem, err_cnt:atomic_dec (&pool->num_elem); -return -EINVAL ; +return err; }void *rxe_pool_get_index (struct rxe_pool *pool,u32 index)
Quoted 20 lines · Zhijian Li (Fujitsu)
Quoted 10 lines · Zhu Yanjun
In the function
__rxe_add_to_pool, the functionxa_alloc_cyclicis called. The return value of the functionxa_alloc_cyclicis as below:
"
Return: 0 if the allocation succeeded without wrapping. 1 if the allocation succeeded after wrapping,-ENOMEMif memory could not be allocated or-EBUSYif there are no free entries in @limit.
"
But now the function__rxe_add_to_poolonly returns-EINVAL. All the returned error value should be returned to the caller.make sense.
Quoted 5 lines
Signed-off-by Zhu Yanjun <[email protected]>--- drivers/infiniband/sw/rxe/rxe_pool.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 7 lines
drivers/infiniband/sw/rxe/rxe_pool.c int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem, · line 122
Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_pool.c +0
-0@@ -122,8 +122,10 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem,int err;I'd like to assign 'err' a default error code:
-EINVAL
Thanks a lot for your comments.
Before the local variable err is used, this variable err has already been set.
As such, it is not necessary to initialize this local variable when it is declared.
Best Regards,
Zhu Yanjun
Quoted 26 lines
Thanks
ZhijianQuoted 19 lines
drivers/infiniband/sw/rxe/rxe_pool.c +4
-2gfp_t gfp_flags; -if (atomic_inc_return (&pool->num_elem) > pool->max_elem) +if (atomic_inc_return (&pool->num_elem) > pool->max_elem) { + err = -EINVAL ; goto err_cnt; + } elem->pool = pool; elem->obj = (u8 *)elem - pool->elem_offset;@@ -147,7 +149,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem, err_cnt:atomic_dec (&pool->num_elem); -return -EINVAL ; +return err; }void *rxe_pool_get_index (struct rxe_pool *pool,u32 index)
Leon Romanovsky
AppliedQuoted 11 lines · Zhu Yanjun
In the function
__rxe_add_to_pool, the functionxa_alloc_cyclicis called. The return value of the functionxa_alloc_cyclicis as below:
"
Return: 0 if the allocation succeeded without wrapping. 1 if the allocation succeeded after wrapping,-ENOMEMif memory could not be allocated or-EBUSYif there are no free entries in @limit.
"
But now the function__rxe_add_to_poolonly returns-EINVAL. All the returned error value should be returned to the caller.[...]
Applied, thanks!
[1/1] RDMA/rxe: Return the correct errno
https://git.kernel.org/rdma/rdma/c/dfcdb38b21e4fb
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>