All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rxe: fix xa_alloc_cycle() error return value check
@ 2022-06-09  6:42 Dongliang Mu
  2022-06-09 17:55 ` Pearson, Robert B
  0 siblings, 1 reply; 2+ messages in thread
From: Dongliang Mu @ 2022-06-09  6:42 UTC (permalink / raw)
  To: Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky
  Cc: Dongliang Mu, linux-rdma, linux-kernel

From: Dongliang Mu <mudongliangabcd@gmail.com>

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 <mudongliangabcd@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] rxe: fix xa_alloc_cycle() error return value check
  2022-06-09  6:42 [PATCH] rxe: fix xa_alloc_cycle() error return value check Dongliang Mu
@ 2022-06-09 17:55 ` Pearson, Robert B
  0 siblings, 0 replies; 2+ messages in thread
From: Pearson, Robert B @ 2022-06-09 17:55 UTC (permalink / raw)
  To: Dongliang Mu, Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky
  Cc: Dongliang Mu, linux-rdma, linux-kernel

Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>

Thanks Mu.

-----Original Message-----
From: Dongliang Mu <dzm91@hust.edu.cn> 
Sent: Thursday, June 9, 2022 1:43 AM
To: Zhu Yanjun <zyjzyj2000@gmail.com>; Jason Gunthorpe <jgg@ziepe.ca>; Leon Romanovsky <leon@kernel.org>
Cc: Dongliang Mu <mudongliangabcd@gmail.com>; linux-rdma@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: [PATCH] rxe: fix xa_alloc_cycle() error return value check

From: Dongliang Mu <mudongliangabcd@gmail.com>

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 <mudongliangabcd@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-09 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09  6:42 [PATCH] rxe: fix xa_alloc_cycle() error return value check Dongliang Mu
2022-06-09 17:55 ` Pearson, Robert B

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.