2022-06-09 06:48:01

by Dongliang Mu

[permalink] [raw]
Subject: [PATCH] rxe: fix xa_alloc_cycle() error return value check

From: Dongliang Mu <[email protected]>

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.

Signed-off-by: Dongliang Mu <[email protected]>
---
drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 19b14826385b..1cc8e847ccff 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -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;
--
2.25.1


2022-06-09 19:20:58

by Pearson, Robert B

[permalink] [raw]
Subject: RE: [PATCH] rxe: fix xa_alloc_cycle() error return value check

Reviewed-by: Bob Pearson <[email protected]>

Thanks Mu.

-----Original Message-----
From: Dongliang Mu <[email protected]>
Sent: Thursday, June 9, 2022 1:43 AM
To: Zhu Yanjun <[email protected]>; Jason Gunthorpe <[email protected]>; Leon Romanovsky <[email protected]>
Cc: Dongliang Mu <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] rxe: fix xa_alloc_cycle() error return value check

From: Dongliang Mu <[email protected]>

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.

Signed-off-by: Dongliang Mu <[email protected]>
---
drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index 19b14826385b..1cc8e847ccff 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -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;
--
2.25.1