[PATCH 1/3] rdma: Fix memory leak in error path
"zhengbing.huang" <[email protected]> Tue, 8 Jul 2025 14:50:38 +0800
| Newsgroups | dev.linux.lists.drbd-dev |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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