]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
RDMA/rtrs: Fix the last iu->buf leak in err path
authorLi Zhijian <lizhijian@fujitsu.com>
Tue, 25 Apr 2023 01:02:42 +0000 (01:02 +0000)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 1 Jun 2023 16:13:02 +0000 (13:13 -0300)
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/1682384563-2-3-git-send-email-lizhijian@fujitsu.com
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/ulp/rtrs/rtrs.c

index 4bf9d868cc522bd8b7631f0f28aba9199385800c..3696f367ff5151333234c707ccad326385fdd59c 100644 (file)
@@ -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;