diff mbox

[03/12] IB/srp: Remove an extraneous scsi_host_put() from an error path

Message ID 5541EE80.6070505@sandisk.com (mailing list archive)
State Rejected
Headers show

Commit Message

Bart Van Assche April 30, 2015, 8:57 a.m. UTC
Fix a scsi_get_host() / scsi_host_put() imbalance in the error
path of srp_create_target(). See also patch "IB/srp: Avoid that
I/O hangs due to a cable pull during LUN scanning" (commit ID
34aa654ecb8e).

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Sebastian Parschauer <sebastian.riemer@profitbricks.com>
Cc: <stable@vger.kernel.org> #v3.19
---
 drivers/infiniband/ulp/srp/ib_srp.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Sagi Grimberg April 30, 2015, 9:44 a.m. UTC | #1
On 4/30/2015 11:57 AM, Bart Van Assche wrote:
> Fix a scsi_get_host() / scsi_host_put() imbalance in the error
> path of srp_create_target(). See also patch "IB/srp: Avoid that
> I/O hangs due to a cable pull during LUN scanning" (commit ID
> 34aa654ecb8e).
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Sagi Grimberg <sagig@mellanox.com>
> Cc: Sebastian Parschauer <sebastian.riemer@profitbricks.com>
> Cc: <stable@vger.kernel.org> #v3.19
> ---
>   drivers/infiniband/ulp/srp/ib_srp.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index 918814c..5ce6cfd 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -3172,11 +3172,11 @@ static ssize_t srp_create_target(struct device *dev,
>
>   	ret = srp_parse_options(buf, target);
>   	if (ret)
> -		goto err;
> +		goto out;
>
>   	ret = scsi_init_shared_tag_map(target_host, target_host->can_queue);
>   	if (ret)
> -		goto err;
> +		goto out;
>
>   	target->req_ring_size = target->queue_size - SRP_TSK_MGMT_SQ_SIZE;
>
> @@ -3187,7 +3187,7 @@ static ssize_t srp_create_target(struct device *dev,
>   			     be64_to_cpu(target->ioc_guid),
>   			     be64_to_cpu(target->initiator_ext));
>   		ret = -EEXIST;
> -		goto err;
> +		goto out;
>   	}
>
>   	if (!srp_dev->has_fmr && !srp_dev->has_fr && !target->allow_ext_sg &&
> @@ -3208,7 +3208,7 @@ static ssize_t srp_create_target(struct device *dev,
>   	spin_lock_init(&target->lock);
>   	ret = ib_query_gid(ibdev, host->port, 0, &target->sgid);
>   	if (ret)
> -		goto err;
> +		goto out;
>
>   	ret = -ENOMEM;
>   	target->ch_count = max_t(unsigned, num_online_nodes(),
> @@ -3219,7 +3219,7 @@ static ssize_t srp_create_target(struct device *dev,
>   	target->ch = kcalloc(target->ch_count, sizeof(*target->ch),
>   			     GFP_KERNEL);
>   	if (!target->ch)
> -		goto err;
> +		goto out;
>
>   	node_idx = 0;
>   	for_each_online_node(node) {
> @@ -3315,9 +3315,6 @@ err_disconnect:
>   	}
>
>   	kfree(target->ch);
> -
> -err:
> -	scsi_host_put(target_host);
>   	goto out;
>   }
>
>

Looks good.

Reviewed-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/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 918814c..5ce6cfd 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -3172,11 +3172,11 @@  static ssize_t srp_create_target(struct device *dev,
 
 	ret = srp_parse_options(buf, target);
 	if (ret)
-		goto err;
+		goto out;
 
 	ret = scsi_init_shared_tag_map(target_host, target_host->can_queue);
 	if (ret)
-		goto err;
+		goto out;
 
 	target->req_ring_size = target->queue_size - SRP_TSK_MGMT_SQ_SIZE;
 
@@ -3187,7 +3187,7 @@  static ssize_t srp_create_target(struct device *dev,
 			     be64_to_cpu(target->ioc_guid),
 			     be64_to_cpu(target->initiator_ext));
 		ret = -EEXIST;
-		goto err;
+		goto out;
 	}
 
 	if (!srp_dev->has_fmr && !srp_dev->has_fr && !target->allow_ext_sg &&
@@ -3208,7 +3208,7 @@  static ssize_t srp_create_target(struct device *dev,
 	spin_lock_init(&target->lock);
 	ret = ib_query_gid(ibdev, host->port, 0, &target->sgid);
 	if (ret)
-		goto err;
+		goto out;
 
 	ret = -ENOMEM;
 	target->ch_count = max_t(unsigned, num_online_nodes(),
@@ -3219,7 +3219,7 @@  static ssize_t srp_create_target(struct device *dev,
 	target->ch = kcalloc(target->ch_count, sizeof(*target->ch),
 			     GFP_KERNEL);
 	if (!target->ch)
-		goto err;
+		goto out;
 
 	node_idx = 0;
 	for_each_online_node(node) {
@@ -3315,9 +3315,6 @@  err_disconnect:
 	}
 
 	kfree(target->ch);
-
-err:
-	scsi_host_put(target_host);
 	goto out;
 }