Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH] RDMA/core: Fix memory leak in __ib_create_cq() on invalid cqe
@ 2026-06-24  2:59 Chenguang Zhao
  2026-06-24  8:38 ` Kalesh Anakkur Purayil
  2026-06-25  2:01 ` [PATCH v2] " Chenguang Zhao
  0 siblings, 2 replies; 5+ messages in thread
From: Chenguang Zhao @ 2026-06-24  2:59 UTC (permalink / raw)
  To: jgg, leon
  Cc: edwards, mbloch, michaelgur, msanalla, ohartoov, jiri,
	kalesh-anakkur.purayil, linux-rdma, Chenguang Zhao

Free the allocated CQ object when cqe is zero before returning
-EINVAL.

Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
---
 drivers/infiniband/core/verbs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 3b613b57e269..d6b2eb820061 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2200,8 +2200,10 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
 	if (!cq)
 		return ERR_PTR(-ENOMEM);
 
-	if (WARN_ON_ONCE(!cq_attr->cqe))
+	if (WARN_ON_ONCE(!cq_attr->cqe)) {
+		kfree(cq);
 		return ERR_PTR(-EINVAL);
+	}
 
 	cq->device = device;
 	cq->comp_handler = comp_handler;
-- 
2.25.1


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

end of thread, other threads:[~2026-07-02 17:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24  2:59 [PATCH] RDMA/core: Fix memory leak in __ib_create_cq() on invalid cqe Chenguang Zhao
2026-06-24  8:38 ` Kalesh Anakkur Purayil
2026-06-25  2:01 ` [PATCH v2] " Chenguang Zhao
2026-06-25  7:32   ` Kalesh Anakkur Purayil
2026-07-02 17:22   ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox