[PATCH 1/3] rdma: Fix memory leak in error path

zhengbing.huang zhengbing.huang at easystack.cn
Tue Jul 8 08:50:38 CEST 2025


In the dtr_send() function, if the __dtr_post_tx_desc() return an error,
it means that  ib_post_send() has failed.
Then, we cannot get this tx_desc and release it through ib_poll_cq().

So, we need to release this tx_desc when __dtr_post_tx_desc() fails in
dtr_send() function.

Signed-off-by: zhengbing.huang <zhengbing.huang at easystack.cn>
---
 drbd/drbd_transport_rdma.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drbd/drbd_transport_rdma.c b/drbd/drbd_transport_rdma.c
index 6de0ba625..5270e503a 100644
--- a/drbd/drbd_transport_rdma.c
+++ b/drbd/drbd_transport_rdma.c
@@ -581,6 +581,9 @@ static int dtr_send(struct dtr_path *path, void *buf, size_t size, gfp_t gfp_mas
 		{ .stream = ST_FLOW_CTRL, .sequence = 0 };
 
 	err = __dtr_post_tx_desc(cm, tx_desc);
+	if (err)
+		dtr_free_tx_desc(cm, tx_desc);
+
 out_put:
 	kref_put(&cm->kref, dtr_destroy_cm);
 out:
-- 
2.43.0



More information about the drbd-dev mailing list