[PATCH 2/4] rdma: Put kref in dtr_remap_tx_desc error

"zhengbing.huang" <[email protected]> Sat, 6 Dec 2025 16:12:25 +0800
Newsgroups dev.linux.lists.drbd-dev
Message-ID <[email protected]>
From: Dongsheng Yang <[email protected]>

The dtr_select_and_get_cm_for_tx() get a ref, we need put it before
continue.

Signed-off-by: Dongsheng Yang <[email protected]>
---
 drbd/drbd_transport_rdma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drbd/drbd_transport_rdma.c b/drbd/drbd_transport_rdma.c
index 3addb7e42..5a28f58f0 100644
--- a/drbd/drbd_transport_rdma.c
+++ b/drbd/drbd_transport_rdma.c
@@ -2391,8 +2391,11 @@ static int dtr_repost_tx_desc(struct dtr_cm *old_cm, struct dtr_tx_desc *tx_desc
 			return -ECONNRESET;
 
 		err = dtr_remap_tx_desc(old_cm, cm, tx_desc);
-		if (err)
+		if (err) {
+			tr_err(&rdma_transport->transport, "dtr_remap_tx_desc failed: %d\n", err);
+			kref_put(&cm->kref, dtr_destroy_cm);
 			continue;
+		}
 
 		err = __dtr_post_tx_desc(cm, tx_desc);
 		if (!err) {
-- 
2.43.0