diff mbox

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

Message ID 1432966330-12230-1-git-send-email-roland@kernel.org (mailing list archive)
State Accepted
Headers show

Commit Message

Roland Dreier May 30, 2015, 6:12 a.m. UTC
From: Roland Dreier <roland@purestorage.com>

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).

Signed-off-by: Roland Dreier <roland@purestorage.com>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Nicholas A. Bellinger May 31, 2015, 3:01 a.m. UTC | #1
On Fri, 2015-05-29 at 23:12 -0700, Roland Dreier wrote:
> From: Roland Dreier <roland@purestorage.com>
> 
> 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).
> 
> Signed-off-by: Roland Dreier <roland@purestorage.com>
> ---
>  drivers/infiniband/ulp/isert/ib_isert.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
> index 327529ee85eb..3f40319a55da 100644
> --- a/drivers/infiniband/ulp/isert/ib_isert.c
> +++ b/drivers/infiniband/ulp/isert/ib_isert.c
> @@ -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;
>  }

Applied to target-pending/master.

Thanks Roland!

--nab


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sagi Grimberg May 31, 2015, 12:54 p.m. UTC | #2
On 5/30/2015 9:12 AM, Roland Dreier wrote:
> From: Roland Dreier <roland@purestorage.com>
>
> 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).
>
> Signed-off-by: Roland Dreier <roland@purestorage.com>
> ---
>   drivers/infiniband/ulp/isert/ib_isert.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
> index 327529ee85eb..3f40319a55da 100644
> --- a/drivers/infiniband/ulp/isert/ib_isert.c
> +++ b/drivers/infiniband/ulp/isert/ib_isert.c
> @@ -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;
>   }
>

Acked-by: Sagi Grimberg <sagig@mellanox.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 327529ee85eb..3f40319a55da 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -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;
 }