summaryrefslogtreecommitdiff
path: root/drivers/scsi/sr.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-03-10 09:29:25 +0700
committerLinus Walleij <linus.walleij@linaro.org>2016-03-10 09:29:25 +0700
commitcc998d8bc74341f6bbbcd63ab4449a6acfc45ee9 (patch)
tree2f4e23fa1ceb83b3e720afd52d9a5ef2be26c77e /drivers/scsi/sr.c
parentd2d13ed01362ecddc3f76f9cca31b0cd5d663a7e (diff)
parent81f70ba233d5f660e1ea5fe23260ee323af5d53a (diff)
Merge tag 'v4.5-rc5' into devel
Linux 4.5-rc5
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r--drivers/scsi/sr.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 8bd54a64efd6..64c867405ad4 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -144,6 +144,9 @@ static int sr_runtime_suspend(struct device *dev)
{
struct scsi_cd *cd = dev_get_drvdata(dev);
+ if (!cd) /* E.g.: runtime suspend following sr_remove() */
+ return 0;
+
if (cd->media_present)
return -EBUSY;
else
@@ -985,6 +988,7 @@ static int sr_remove(struct device *dev)
scsi_autopm_get_device(cd->device);
del_gendisk(cd->disk);
+ dev_set_drvdata(dev, NULL);
mutex_lock(&sr_ref_mutex);
kref_put(&cd->kref, sr_kref_release);