Upgrade to 4.4.50-rt62
[kvmfornfv.git] / kernel / drivers / scsi / scsi_scan.c
index 054923e..692445b 100644 (file)
@@ -314,6 +314,7 @@ static void scsi_target_destroy(struct scsi_target *starget)
        struct Scsi_Host *shost = dev_to_shost(dev->parent);
        unsigned long flags;
 
+       BUG_ON(starget->state == STARGET_DEL);
        starget->state = STARGET_DEL;
        transport_destroy_device(dev);
        spin_lock_irqsave(shost->host_lock, flags);
@@ -1458,12 +1459,12 @@ retry:
  out_err:
        kfree(lun_data);
  out:
-       scsi_device_put(sdev);
        if (scsi_device_created(sdev))
                /*
                 * the sdev we used didn't appear in the report luns scan
                 */
                __scsi_remove_device(sdev);
+       scsi_device_put(sdev);
        return ret;
 }