* [PATCH v2] RDMA/irdma: do not acquire zero-reference listeners
@ 2026-12-03 3:16 Jaeyeong Lee
2026-12-03 3:31 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Jaeyeong Lee @ 2026-12-03 3:16 UTC (permalink / raw)
To: linux-rdma
Cc: Tatyana Nikolova, Jason Gunthorpe, Leon Romanovsky, linux-kernel
irdma_dec_refcnt_listen() can drop a listener reference count to zero
before taking listen_list_lock to remove it from the lookup list. During
this window, irdma_find_listener() can find the listener and call
refcount_inc() on the zero count. It then returns a listener that the
teardown path is about to free.
Use refcount_inc_not_zero() while holding listen_list_lock. If the
listener has reached zero, skip it and let the teardown path remove it
from the list.
Fixes: 146b9756f14c ("RDMA/irdma: Add connection manager")
Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
---
Changes since v1:
- Avoid acquiring a zero reference in the lookup path instead of moving
the final decrement under listen_list_lock.
drivers/infiniband/hw/irdma/cm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/irdma/cm.c b/drivers/infiniband/hw/irdma/cm.c
index bc30e465c..8a84b6aef 100644
--- a/drivers/infiniband/hw/irdma/cm.c
+++ b/drivers/infiniband/hw/irdma/cm.c
@@ -1487,7 +1487,8 @@ irdma_find_listener(struct irdma_cm_core *cm_core, u32 *dst_addr, bool ipv4,
if (!memcmp(listen_addr, ip_zero, sizeof(listen_addr)) ||
(!memcmp(listen_addr, dst_addr, sizeof(listen_addr)) &&
vlan_id == listen_node->vlan_id)) {
- refcount_inc(&listen_node->refcnt);
+ if (!refcount_inc_not_zero(&listen_node->refcnt))
+ continue;
spin_unlock_irqrestore(&cm_core->listen_list_lock,
flags);
trace_irdma_find_listener(listen_node);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 3:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 3:16 [PATCH v2] RDMA/irdma: do not acquire zero-reference listeners Jaeyeong Lee
2026-12-03 3:31 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox