diff mbox series

RDMA/rxe: Fix memleak in rxe_mem_init_user

Message ID 20200819075632.22285-1-dinghao.liu@zju.edu.cn (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/rxe: Fix memleak in rxe_mem_init_user | expand

Commit Message

Dinghao Liu Aug. 19, 2020, 7:56 a.m. UTC
When page_address() fails, umem should be freed just
like when rxe_mem_alloc() fails.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/infiniband/sw/rxe/rxe_mr.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Zhu Yanjun Aug. 19, 2020, 8:38 a.m. UTC | #1
On Wed, Aug 19, 2020 at 3:59 PM Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
>
> When page_address() fails, umem should be freed just
> like when rxe_mem_alloc() fails.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/infiniband/sw/rxe/rxe_mr.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
> index cdd811a45120..ce24144de16a 100644
> --- a/drivers/infiniband/sw/rxe/rxe_mr.c
> +++ b/drivers/infiniband/sw/rxe/rxe_mr.c
> @@ -205,6 +205,7 @@ int rxe_mem_init_user(struct rxe_pd *pd, u64 start,
>                         vaddr = page_address(sg_page_iter_page(&sg_iter));
>                         if (!vaddr) {
>                                 pr_warn("null vaddr\n");
> +                               ib_umem_release(umem);
seems reasonable.

Thanks,

Zhu Yanjun
>                                 err = -ENOMEM;
>                                 goto err1;
>                         }
> --
> 2.17.1
>
Jason Gunthorpe Aug. 27, 2020, 11:47 a.m. UTC | #2
On Wed, Aug 19, 2020 at 03:56:32PM +0800, Dinghao Liu wrote:
> When page_address() fails, umem should be freed just
> like when rxe_mem_alloc() fails.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/infiniband/sw/rxe/rxe_mr.c | 1 +
>  1 file changed, 1 insertion(+)

Applied to for-rc, I added a fixes line

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
index cdd811a45120..ce24144de16a 100644
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -205,6 +205,7 @@  int rxe_mem_init_user(struct rxe_pd *pd, u64 start,
 			vaddr = page_address(sg_page_iter_page(&sg_iter));
 			if (!vaddr) {
 				pr_warn("null vaddr\n");
+				ib_umem_release(umem);
 				err = -ENOMEM;
 				goto err1;
 			}