Merge tag 'dlm-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm
[linux-2.6-block.git] / drivers / scsi / scsi_error.c
index 78b004da288518e2a2d9279eca7d32c2fe9bbc42..771c16bfdbac4be2fac180459ff5711407c98a01 100644 (file)
@@ -2288,6 +2288,11 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
        if (scsi_autopm_get_host(shost) < 0)
                return FAILED;
 
+       if (!get_device(&dev->sdev_gendev)) {
+               rtn = FAILED;
+               goto out_put_autopm_host;
+       }
+
        scmd = scsi_get_command(dev, GFP_KERNEL);
        blk_rq_init(NULL, &req);
        scmd->request = &req;
@@ -2345,6 +2350,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
        scsi_run_host_queues(shost);
 
        scsi_next_command(scmd);
+out_put_autopm_host:
        scsi_autopm_put_host(shost);
        return rtn;
 }