Commit 1c69d3b6 authored by Ken Xue's avatar Ken Xue Committed by Martin K. Petersen

Revert "SCSI: Fix NULL pointer dereference in runtime PM"

This reverts commit 49718f0f ("SCSI: Fix NULL pointer dereference in
runtime PM")

The old commit may lead to a issue that blk_{pre|post}_runtime_suspend and
blk_{pre|post}_runtime_resume may not be called in pairs.

Take sr device as example, when sr device goes to runtime suspend,
blk_{pre|post}_runtime_suspend will be called since sr device defined
pm->runtime_suspend. But blk_{pre|post}_runtime_resume will not be called
since sr device doesn't have pm->runtime_resume. so, sr device can not
resume correctly anymore.

More discussion can be found from below link.
http://marc.info/?l=linux-scsi&m=144163730531875&w=2Signed-off-by: default avatarKen Xue <Ken.Xue@amd.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Cc: Xiangliang Yu <Xiangliang.Yu@amd.com>
Cc: James E.J. Bottomley <JBottomley@odin.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Michael Terry <Michael.terry@canonical.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 527e9316
...@@ -219,13 +219,13 @@ static int sdev_runtime_suspend(struct device *dev) ...@@ -219,13 +219,13 @@ static int sdev_runtime_suspend(struct device *dev)
struct scsi_device *sdev = to_scsi_device(dev); struct scsi_device *sdev = to_scsi_device(dev);
int err = 0; int err = 0;
if (pm && pm->runtime_suspend) { err = blk_pre_runtime_suspend(sdev->request_queue);
err = blk_pre_runtime_suspend(sdev->request_queue); if (err)
if (err) return err;
return err; if (pm && pm->runtime_suspend)
err = pm->runtime_suspend(dev); err = pm->runtime_suspend(dev);
blk_post_runtime_suspend(sdev->request_queue, err); blk_post_runtime_suspend(sdev->request_queue, err);
}
return err; return err;
} }
...@@ -248,11 +248,11 @@ static int sdev_runtime_resume(struct device *dev) ...@@ -248,11 +248,11 @@ static int sdev_runtime_resume(struct device *dev)
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int err = 0; int err = 0;
if (pm && pm->runtime_resume) { blk_pre_runtime_resume(sdev->request_queue);
blk_pre_runtime_resume(sdev->request_queue); if (pm && pm->runtime_resume)
err = pm->runtime_resume(dev); err = pm->runtime_resume(dev);
blk_post_runtime_resume(sdev->request_queue, err); blk_post_runtime_resume(sdev->request_queue, err);
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment