diff mbox

IB/iser: fix possible memory leak in iser_create_frwr_pool

Message ID 1376919711-23732-1-git-send-email-roid@mellanox.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Roi Dayan Aug. 19, 2013, 1:41 p.m. UTC
where desc is not being freed in error flows.

Signed-off-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
---
 drivers/infiniband/ulp/iser/iser_verbs.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 28badac..afe9567 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;