target: fix null pointer regression in core_tmr_drain_tmr_list
authortangwenji <tang.wenji@zte.com.cn>
Wed, 16 Aug 2017 08:39:00 +0000 (16:39 +0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Sat, 4 Nov 2017 21:45:20 +0000 (14:45 -0700)
The target system kernel crash when the initiator executes
the sg_persist -A command,because of the second argument to
be set to NULL when core_tmr_lun_reset is called in
core_scsi3_pro_preempt function.

This fixes a regression originally introduced by:

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

      target: Delete tmr from list before processing

Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
Cc: stable@vger.kernel.org # 4.11+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_tmr.c

index e22847b..61909b2 100644 (file)
@@ -217,7 +217,8 @@ static void core_tmr_drain_tmr_list(
         * LUN_RESET tmr..
         */
        spin_lock_irqsave(&dev->se_tmr_lock, flags);
-       list_del_init(&tmr->tmr_list);
+       if (tmr)
+               list_del_init(&tmr->tmr_list);
        list_for_each_entry_safe(tmr_p, tmr_pp, &dev->dev_tmr_list, tmr_list) {
                cmd = tmr_p->task_cmd;
                if (!cmd) {