Re: [PATCH v2 17/36] target: Fix a reference leak in transport_cmd_check_stop_to_fabric()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2017-02-01 at 16:58 -0800, 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@xxxxxxxxxxx>
> Reviewed-by: Hannes Reinecke <hare@xxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>
> Cc: Andy Grover <agrover@xxxxxxxxxx>
> Cc: David Disseldorp <ddiss@xxxxxxx>
> ---
>  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 d241c4d27352..25bc214a4eee 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -628,13 +628,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

Separate from this patch series, this not a bug.

Note the existing callers of __transport_wait_for_tasks() that does
wait_for_completion(&cmd->t_transport_stop_comp) currently expects to
drop any outstanding se_cmd->cmd_kref from it's own calling context,
once CMD_T_STOP has been intercepted from this completion callback, and
cleared in __transport_wait_for_tasks().

It works the same way above in transport_cmd_check_stop(), as well as
CMD_T_STOP checks in target_complete_cmd() and target_execute_cmd().


--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux