diff mbox

[15/34] target: Fix a reference leak in transport_cmd_check_stop_to_fabric()

Message ID 20170125233646.2243-16-bart.vanassche@sandisk.com (mailing list archive)
State Superseded
Headers show

Commit Message

Bart Van Assche Jan. 25, 2017, 11:36 p.m. UTC
Avoid that transport_cmd_check_stop_to_fabric() leaks a command
reference if CMD_T_STOP has been set.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andy Grover <agrover@redhat.com>
Cc: David Disseldorp <ddiss@suse.de>
---
 drivers/target/target_core_transport.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Hannes Reinecke Jan. 26, 2017, 8 a.m. UTC | #1
On 01/26/2017 12:36 AM, Bart Van Assche wrote:
> Avoid that transport_cmd_check_stop_to_fabric() leaks a command
> reference if CMD_T_STOP has been set.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Andy Grover <agrover@redhat.com>
> Cc: David Disseldorp <ddiss@suse.de>
> ---
>  drivers/target/target_core_transport.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index f7b31cade25e..df23883869fb 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -614,13 +614,11 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists,
>  		pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n",
>  			__func__, __LINE__, cmd->tag);
>  
> -		spin_unlock_irqrestore(&cmd->t_state_lock, flags);
> -
>  		complete_all(&cmd->t_transport_stop_comp);
> -		return 1;
> +	} else {
> +		cmd->transport_state &= ~CMD_T_ACTIVE;
>  	}
>  
> -	cmd->transport_state &= ~CMD_T_ACTIVE;
>  	if (remove_from_lists) {
>  		/*
>  		 * Some fabric modules like tcm_loop can release
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
diff mbox

Patch

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index f7b31cade25e..df23883869fb 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -614,13 +614,11 @@  static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists,
 		pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n",
 			__func__, __LINE__, cmd->tag);
 
-		spin_unlock_irqrestore(&cmd->t_state_lock, flags);
-
 		complete_all(&cmd->t_transport_stop_comp);
-		return 1;
+	} else {
+		cmd->transport_state &= ~CMD_T_ACTIVE;
 	}
 
-	cmd->transport_state &= ~CMD_T_ACTIVE;
 	if (remove_from_lists) {
 		/*
 		 * Some fabric modules like tcm_loop can release