From 27ae2d1ea578dce73ab5368a6bf31c342004e709 Mon Sep 17 00:00:00 2001 From: Roi Dayan Date: Mon, 19 Aug 2013 16:41:51 +0300 Subject: IB/iser: Fix possible memory leak in iser_create_frwr_pool() Fix leak where desc is not being freed in error flows. Signed-off-by: Roi Dayan Signed-off-by: Sagi Grimberg Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/iser/iser_verbs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers/infiniband/ulp') diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 28badacb0134..afe95674008b 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c @@ -305,7 +305,7 @@ int iser_create_frwr_pool(struct iser_conn *ib_conn, unsigned cmds_max) if (IS_ERR(desc->data_frpl)) { ret = PTR_ERR(desc->data_frpl); iser_err("Failed to allocate ib_fast_reg_page_list err=%d\n", ret); - goto err; + goto fast_reg_page_failure; } desc->data_mr = ib_alloc_fast_reg_mr(device->pd, @@ -313,8 +313,7 @@ int iser_create_frwr_pool(struct iser_conn *ib_conn, unsigned cmds_max) if (IS_ERR(desc->data_mr)) { ret = PTR_ERR(desc->data_mr); iser_err("Failed to allocate ib_fast_reg_mr err=%d\n", ret); - ib_free_fast_reg_page_list(desc->data_frpl); - goto err; + goto fast_reg_mr_failure; } desc->valid = true; list_add_tail(&desc->list, &ib_conn->fastreg.frwr.pool); @@ -322,6 +321,11 @@ int iser_create_frwr_pool(struct iser_conn *ib_conn, unsigned cmds_max) } return 0; + +fast_reg_mr_failure: + ib_free_fast_reg_page_list(desc->data_frpl); +fast_reg_page_failure: + kfree(desc); err: iser_free_frwr_pool(ib_conn); return ret; -- cgit v1.2.3