All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next] RDMA/restrack: Don't treat as an error allocation ID wrapping
@ 2020-12-16 10:07 Leon Romanovsky
  2021-01-07 18:32 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Leon Romanovsky @ 2020-12-16 10:07 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: Leon Romanovsky, Dan Carpenter, linux-rdma

From: Leon Romanovsky <leonro@nvidia.com>

xa_alloc_cyclic() call returns positive number if ID allocation
succeeded but wrapped. It is not an error, so normalize the "ret"
variable to zero as marker of not-an-error.

   drivers/infiniband/core/restrack.c:261 rdma_restrack_add()
   warn: 'ret' can be either negative or positive

Fixes: fd47c2f99f04 ("RDMA/restrack: Convert internal DB from hash to XArray")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/core/restrack.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
index 53a8005972a8..5226ac0e0e07 100644
--- a/drivers/infiniband/core/restrack.c
+++ b/drivers/infiniband/core/restrack.c
@@ -257,6 +257,7 @@ int rdma_restrack_add(struct rdma_restrack_entry *res)
 	default:
 		ret = xa_alloc_cyclic(&rt->xa, &res->id, res, xa_limit_32b,
 				      &rt->next_id, GFP_KERNEL);
+		ret = (ret < 0) ? ret : 0;
 	}
 	if (ret) {
 		ibdev_err(
-- 
2.29.2


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

* Re: [PATCH rdma-next] RDMA/restrack: Don't treat as an error allocation ID wrapping
  2020-12-16 10:07 [PATCH rdma-next] RDMA/restrack: Don't treat as an error allocation ID wrapping Leon Romanovsky
@ 2021-01-07 18:32 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-01-07 18:32 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Doug Ledford, Leon Romanovsky, Dan Carpenter, linux-rdma

On Wed, Dec 16, 2020 at 12:07:53PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> xa_alloc_cyclic() call returns positive number if ID allocation
> succeeded but wrapped. It is not an error, so normalize the "ret"
> variable to zero as marker of not-an-error.
> 
>    drivers/infiniband/core/restrack.c:261 rdma_restrack_add()
>    warn: 'ret' can be either negative or positive
> 
> Fixes: fd47c2f99f04 ("RDMA/restrack: Convert internal DB from hash to XArray")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>  drivers/infiniband/core/restrack.c | 1 +
>  1 file changed, 1 insertion(+)

Applied to for-rc, thanks

Jason

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

end of thread, other threads:[~2021-01-07 18:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 10:07 [PATCH rdma-next] RDMA/restrack: Don't treat as an error allocation ID wrapping Leon Romanovsky
2021-01-07 18:32 ` Jason Gunthorpe

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.