Skip to contentSkip to conversation

iser-target: Fix error path in isert_create_pi_ctx()

PATCH Applied Roland Dreier 3 participants 3 messages May 30, 2015 – May 31, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 iser-target: Fix error path in isert_create_pi_ctx()

From: Roland Dreier <[email protected]>

We don't assign pi_ctx to desc->pi_ctx until we're certain to succeed in the function. That means the cleanup path should use the local pi_ctx variable, not desc->pi_ctx.

This was detected by Coverity (CID 1260062).

---
 drivers/infiniband/ulp/isert/ib_isert.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +3 -3
index 327529ee85eb..3f40319a55da 100644
@@ -547,11 +547,11 @@ isert_create_pi_ctx(struct fast_reg_descriptor *desc,
 	return 0;
 
 err_prot_mr:
-	ib_dereg_mr(desc->pi_ctx->prot_mr);
+	ib_dereg_mr(pi_ctx->prot_mr);
 err_prot_frpl:
-	ib_free_fast_reg_page_list(desc->pi_ctx->prot_frpl);
+	ib_free_fast_reg_page_list(pi_ctx->prot_frpl);
 err_pi_ctx:
-	kfree(desc->pi_ctx);
+	kfree(pi_ctx);
 
 	return ret;
 }
Signature · 1 line
2.1.4
#1 lore raw
Quoted 22 lines · Roland Dreier

From: Roland Dreier <[email protected]>

We don't assign pi_ctx to desc->pi_ctx until we're certain to succeed in the function. That means the cleanup path should use the local pi_ctx variable, not desc->pi_ctx.

This was detected by Coverity (CID 1260062).

---
 drivers/infiniband/ulp/isert/ib_isert.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +0 -1
index 327529ee85eb..3f40319a55da 100644
@@ -547,11 +547,11 @@ isert_create_pi_ctx(struct fast_reg_descriptor *desc,
 	return 0;
 
 err_prot_mr:
-	ib_dereg_mr(desc->pi_ctx->prot_mr);

drivers/infiniband/ulp/isert/ib_isert.c isert_create_pi_ctx(struct fast_reg_descriptor *desc, · line 557

Quoted 10 lines
drivers/infiniband/ulp/isert/ib_isert.c +3 -2
+	ib_dereg_mr(pi_ctx->prot_mr);
 err_prot_frpl:
-	ib_free_fast_reg_page_list(desc->pi_ctx->prot_frpl);
+	ib_free_fast_reg_page_list(pi_ctx->prot_frpl);
 err_pi_ctx:
-	kfree(desc->pi_ctx);
+	kfree(pi_ctx);
 
 	return ret;
 }

Applied to target-pending/master.

Thanks Roland!

--nab

Acked-by on v1 3/3
#2 lore raw
In reply to Roland Dreier
Quoted 23 lines · Roland Dreier

From: Roland Dreier <[email protected]>

We don't assign pi_ctx to desc->pi_ctx until we're certain to succeed in the function. That means the cleanup path should use the local pi_ctx variable, not desc->pi_ctx.

This was detected by Coverity (CID 1260062).

---
  drivers/infiniband/ulp/isert/ib_isert.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +0 -1
index 327529ee85eb..3f40319a55da 100644
@@ -547,11 +547,11 @@ isert_create_pi_ctx(struct fast_reg_descriptor *desc,
  	return 0;
 
  err_prot_mr:
-	ib_dereg_mr(desc->pi_ctx->prot_mr);

drivers/infiniband/ulp/isert/ib_isert.c isert_create_pi_ctx(struct fast_reg_descriptor *desc, · line 557

Quoted 10 lines
drivers/infiniband/ulp/isert/ib_isert.c +3 -2
+	ib_dereg_mr(pi_ctx->prot_mr);
  err_prot_frpl:
-	ib_free_fast_reg_page_list(desc->pi_ctx->prot_frpl);
+	ib_free_fast_reg_page_list(pi_ctx->prot_frpl);
  err_pi_ctx:
-	kfree(desc->pi_ctx);
+	kfree(pi_ctx);
 
  	return ret;
  }