RDMA/rxe: Fix memleak in rxe_mem_init_user
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Wed, 19 Aug 2020 07:56:32 +0000 (15:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Sep 2020 06:46:09 +0000 (08:46 +0200)
[ Upstream commit e3ddd6067ee62f6e76ebcf61ff08b2c729ae412b ]

When page_address() fails, umem should be freed just like when
rxe_mem_alloc() fails.

Fixes: 8700e3e7c485 ("Soft RoCE driver")
Link: https://lore.kernel.org/r/20200819075632.22285-1-dinghao.liu@zju.edu.cn
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/sw/rxe/rxe_mr.c

index 9b732c5..6d1ba75 100644 (file)
@@ -205,6 +205,7 @@ int rxe_mem_init_user(struct rxe_dev *rxe, struct rxe_pd *pd, u64 start,
                        vaddr = page_address(sg_page(sg));
                        if (!vaddr) {
                                pr_warn("null vaddr\n");
+                               ib_umem_release(umem);
                                err = -ENOMEM;
                                goto err1;
                        }