]> git.baikalelectronics.ru Git - kernel.git/commit
target: Fix caw_sem leak in transport_generic_request_failure
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 29 Sep 2017 23:03:24 +0000 (16:03 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 8 Nov 2017 03:43:55 +0000 (19:43 -0800)
commit14a6e8d060d68ff44ec23d1d37e6d3ed5a50c122
tree8f7b0b40eaeb20a6eb2bddb6a1f6a705198f543a
parent4207064dc4df4662aa72c1f12172fd44cc58d7cf
target: Fix caw_sem leak in transport_generic_request_failure

With the recent addition of transport_check_aborted_status() within
transport_generic_request_failure() to avoid sending a SCSI status
exception after CMD_T_ABORTED w/ TAS=1 has occured, it introduced
a COMPARE_AND_WRITE early failure regression.

Namely when COMPARE_AND_WRITE fails and se_device->caw_sem has
been taken by sbc_compare_and_write(), if the new check for
transport_check_aborted_status() returns true and exits,
cmd->transport_complete_callback() -> compare_and_write_post()
is skipped never releasing se_device->caw_sem.

This regression was originally introduced by:

  commit c17d4be0debd96d432340ccd9402bd11deb35577
  Author: Bart Van Assche <bart.vanassche@sandisk.com>
  Date:   Tue Feb 14 16:25:45 2017 -0800

      target: Fix handling of aborted failed commands

To address this bug, move the transport_check_aborted_status()
call after transport_complete_task_attr() and
cmd->transport_complete_callback().

Cc: Mike Christie <mchristi@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: stable@vger.kernel.org # 4.11+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_transport.c