All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next] RDMA/irdma: Free cq with a safer cq num reference
@ 2026-10-30 17:32 David Hu
  2026-10-30 17:37 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: David Hu @ 2026-10-30 17:32 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky, Tatyana Nikolova
  Cc: Jacob Moroni, linux-rdma, linux-kernel, David Hu, sashiko-bot

From: David Hu <xuehaohu@google.com>

Within a iwcq, `cq_num` is allocated first, and only
copied to an inner uk structure, `cq_uk.cq_id` at a
later stage. Freeing cq by `cq_uk.cq_id` before the
later stage leads to a cq id leak.

Free `iwcq->cq_num` instead, which is allocated
right after initial rsrc allocation.

Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20261016202909.1289496-1-dhu@x6u.co?part=4
Signed-off-by: David Hu <xuehaohu@google.com>
---
 drivers/infiniband/hw/irdma/verbs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index c91c55917de9..1726a0ddeac8 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -1948,8 +1948,6 @@ static void irdma_srq_free_rsrc(struct irdma_pci_f *rf, struct irdma_srq *iwsrq)
  */
 static void irdma_cq_free_rsrc(struct irdma_pci_f *rf, struct irdma_cq *iwcq)
 {
-	struct irdma_sc_cq *cq = &iwcq->sc_cq;
-
 	if (!iwcq->user_mode) {
 		dma_free_coherent(rf->sc_dev.hw->device, iwcq->kmem.size,
 				  iwcq->kmem.va, iwcq->kmem.pa);
@@ -1975,7 +1973,7 @@ static void irdma_cq_free_rsrc(struct irdma_pci_f *rf, struct irdma_cq *iwcq)
 		}
 	}
 
-	irdma_free_rsrc(rf, rf->allocated_cqs, cq->cq_uk.cq_id);
+	irdma_free_rsrc(rf, rf->allocated_cqs, iwcq->cq_num);
 }
 
 /**

base-commit: c3e8e9451e6f1b69f685b75e0fbf14f3d0fb2539
-- 
2.56.0.317.g454f8302e1-goog


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

* Re: [PATCH rdma-next] RDMA/irdma: Free cq with a safer cq num reference
  2026-10-30 17:32 [PATCH rdma-next] RDMA/irdma: Free cq with a safer cq num reference David Hu
@ 2026-10-30 17:37 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-30 17:37 UTC (permalink / raw)
  To: David Hu; +Cc: linux-rdma

> From: David Hu <xuehaohu@google.com>
> 
> Within a iwcq, `cq_num` is allocated first, and only
> copied to an inner uk structure, `cq_uk.cq_id` at a
> later stage. Freeing cq by `cq_uk.cq_id` before the
> later stage leads to a cq id leak.
> 
> Free `iwcq->cq_num` instead, which is allocated
> right after initial rsrc allocation.
> 
> Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
> Reported-by: sashiko-bot <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20261016202909.1289496-1-dhu@x6u.co?part=4
> Signed-off-by: David Hu <xuehaohu@google.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261030173254.2000665-1-dhu@x6u.co?part=1


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

end of thread, other threads:[~2026-10-30 17:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 17:32 [PATCH rdma-next] RDMA/irdma: Free cq with a safer cq num reference David Hu
2026-10-30 17:37 ` sashiko-bot

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.