Re: [PATCH 1/3] rdma: Fix memory leak in error path
Philipp Reisner <[email protected]> Wed, 30 Jul 2025 16:16:51 +0200
| Newsgroups | dev.linux.lists.drbd-dev |
|---|---|
| Message-ID | <CADGDV=V98XMcgGXcbnS7NcP2cWcfpnHwy=GgmY1p8EhZr3QCjg@mail.gmail.com> |
Thanks, applied On Tue, Jul 8, 2025 at 12:20 PM zhengbing.huang < [email protected]> wrote: > 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 > >