Message ID | 1682213212-2-3-git-send-email-lizhijian@fujitsu.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | RDMA/rtrs: bugfix and cleanups | expand |
On 4/23/23 09:26, Li Zhijian wrote: > The last iu->buf will leak if ib_dma_mapping_error() fails. Fixes: c0894b3ea69d("RDMA/rtrs: core: lib functions shared between client and server modules") > Signed-off-by: Li Zhijian<lizhijian@fujitsu.com> > --- > V2: new patch to address memory leaking > --- > drivers/infiniband/ulp/rtrs/rtrs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c > index 4bf9d868cc52..3696f367ff51 100644 > --- a/drivers/infiniband/ulp/rtrs/rtrs.c > +++ b/drivers/infiniband/ulp/rtrs/rtrs.c > @@ -37,8 +37,10 @@ struct rtrs_iu *rtrs_iu_alloc(u32 iu_num, size_t size, gfp_t gfp_mask, > goto err; > > iu->dma_addr = ib_dma_map_single(dma_dev, iu->buf, size, dir); > - if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) > + if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) { > + kfree(iu->buf); > goto err; > + } > > iu->cqe.done = done; > iu->size = size; Good catch, Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev> Thanks, Guoqing
On Sun, Apr 23, 2023 at 3:27 AM Li Zhijian <lizhijian@fujitsu.com> wrote: > > The last iu->buf will leak if ib_dma_mapping_error() fails. > > Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> Yes, as guoqing suggested, please add the Fixes tag. Acked-by: Jack Wang <jinpu.wang@ionos.com> > --- > V2: new patch to address memory leaking > --- > drivers/infiniband/ulp/rtrs/rtrs.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c > index 4bf9d868cc52..3696f367ff51 100644 > --- a/drivers/infiniband/ulp/rtrs/rtrs.c > +++ b/drivers/infiniband/ulp/rtrs/rtrs.c > @@ -37,8 +37,10 @@ struct rtrs_iu *rtrs_iu_alloc(u32 iu_num, size_t size, gfp_t gfp_mask, > goto err; > > iu->dma_addr = ib_dma_map_single(dma_dev, iu->buf, size, dir); > - if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) > + if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) { > + kfree(iu->buf); > goto err; > + } > > iu->cqe.done = done; > iu->size = size; > -- > 2.29.2 >
diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 4bf9d868cc52..3696f367ff51 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -37,8 +37,10 @@ struct rtrs_iu *rtrs_iu_alloc(u32 iu_num, size_t size, gfp_t gfp_mask, goto err; iu->dma_addr = ib_dma_map_single(dma_dev, iu->buf, size, dir); - if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) + if (ib_dma_mapping_error(dma_dev, iu->dma_addr)) { + kfree(iu->buf); goto err; + } iu->cqe.done = done; iu->size = size;
The last iu->buf will leak if ib_dma_mapping_error() fails. Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> --- V2: new patch to address memory leaking --- drivers/infiniband/ulp/rtrs/rtrs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)