Skip to content

Commit

Permalink
RDMA/rxe: fix xa_alloc_cycle() error return value check again
Browse files Browse the repository at this point in the history
Currently rxe_alloc checks ret to indicate error, but 1 is also a valid
return and just indicates that the allocation succeeded with a wrap.

Fix this by modifying the check to be < 0.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 3225717 ("RDMA/rxe: Replace red-black trees by xarrays")
Signed-off-by: Dongliang Mu <[email protected]>
Reviewed-by: Bob Pearson <[email protected]>
Signed-off-by: Leon Romanovsky <[email protected]>
  • Loading branch information
mudongliang authored and rleon committed Jun 16, 2022
1 parent d56e336 commit 1a68594
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void *rxe_alloc(struct rxe_pool *pool)

err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit,
&pool->next, GFP_KERNEL);
if (err)
if (err < 0)
goto err_free;

return obj;
Expand Down Expand Up @@ -167,7 +167,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem)

err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit,
&pool->next, GFP_KERNEL);
if (err)
if (err < 0)
goto err_cnt;

return 0;
Expand Down

0 comments on commit 1a68594

Please sign in to comment.