summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/scsi/sr.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/scsi/sr.c')
-rw-r--r--kernel/drivers/scsi/sr.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/drivers/scsi/sr.c b/kernel/drivers/scsi/sr.c
index 8bd54a64e..64c867405 100644
--- a/kernel/drivers/scsi/sr.c
+++ b/kernel/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);