aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Zhijian <[email protected]>2023-04-25 01:02:42 +0000
committerJason Gunthorpe <[email protected]>2023-06-01 13:13:02 -0300
commit3bf3a7c6985c625f64e73baefdaa36f1c2045a29 (patch)
treed5c196cb9daa187e4fe0dbfcc718871c4d249d12
parent5842d1d9c1b0d17e0c29eae65ae1f245f83682dd (diff)
RDMA/rtrs: Fix the last iu->buf leak in err path
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") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Li Zhijian <[email protected]> Acked-by: Guoqing Jiang <[email protected]> Acked-by: Jack Wang <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
-rw-r--r--drivers/infiniband/ulp/rtrs/rtrs.c4
1 files changed, 3 insertions, 1 deletions
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;