Skip to contentSkip to conversation

RDMA/restrack: Don't treat as an error allocation ID wrapping

PATCH Applied Leon Romanovsky 2 participants 2 messages Dec 16, 2020 – Jan 7, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/restrack: Don't treat as an error allocation ID wrapping

From: Leon Romanovsky <[email protected]>

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")
---
 drivers/infiniband/core/restrack.c | 1 +
 1 file changed, 1 insertion(+)
drivers/infiniband/core/restrack.c +1 -0
index 53a8005972a8..5226ac0e0e07 100644
@@ -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(
Signature · 1 line
2.29.2
maintainer Applied
#1 lore raw
Quoted 9 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

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

Quoted 6 lines
Fixes fd47c2f99f04 ("RDMA/restrack: Convert internal DB from hash to XArray")
---
 drivers/infiniband/core/restrack.c | 1 +
 1 file changed, 1 insertion(+)

Applied to for-rc, thanks

Jason