RDMA/rxe: fix xa_alloc_cycle() error return value check again
authorDongliang Mu <mudongliangabcd@gmail.com>
Thu, 9 Jun 2022 07:06:56 +0000 (15:06 +0800)
committerLeon Romanovsky <leonro@nvidia.com>
Thu, 16 Jun 2022 17:07:07 +0000 (20:07 +0300)
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/20220609070656.1446121-1-dzm91@hust.edu.cn
Fixes: 3225717f6dfa ("RDMA/rxe: Replace red-black trees by xarrays")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/sw/rxe/rxe_pool.c

index 19b1482..e9f3bbd 100644 (file)
@@ -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;
@@ -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;