diff mbox

[1/2] Revert "SCSI: Fix NULL pointer dereference in runtime PM"

Message ID 1441851826.5845.105.camel@kxue-X58A-UD3R (mailing list archive)
State New, archived
Headers show

Commit Message

Ken Xue Sept. 10, 2015, 2:23 a.m. UTC
Revert "SCSI: Fix NULL pointer dereference in runtime PM"

This reverts commit 49718f0fb8c9 ("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 can 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. Then sr device can not
resume correctly anymore.

Signed-off-by: Ken Xue <Ken.Xue@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable@vger.kernel.org

---
 drivers/scsi/scsi_pm.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

Ken Xue Nov. 27, 2015, 3:01 a.m. UTC | #1
T24g5ZubLCAyMDE1LTA5LTEwIGF0IDEwOjIzICswODAwLCBLZW4gWHVlIHdyb3RlOg0KDQpDYW4g
c29tZW9uZSBoZWxwIHRvIGFwcGx5IHRoaXMgcGF0Y2ggc2VyaWVzPyBUaGFua3MuDQpodHRwOi8v
bWFyYy5pbmZvLz9sPWxpbnV4LXNjc2kmbT0xNDQxODUyMDY4MjU2MDkmdz0yDQpodHRwOi8vbWFy
Yy5pbmZvLz9sPWxpbnV4LXNjc2kmbT0xNDQxODUyMDg1MjU2MTEmdz0yIA0KDQo+IFJldmVydCAi
U0NTSTogRml4IE5VTEwgcG9pbnRlciBkZXJlZmVyZW5jZSBpbiBydW50aW1lIFBNIg0KPiANCj4g
VGhpcyByZXZlcnRzIGNvbW1pdCA0OTcxOGYwZmI4YzkgKCJTQ1NJOiBGaXggTlVMTCBwb2ludGVy
IGRlcmVmZXJlbmNlDQo+IGluDQo+IHJ1bn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W1lX3Jlc3VtZShzdHJ1Y3Qg
ZGV2aWNlDQo+ICpkZXYpDQo+ICAJY29uc3Qgc3RydWN0IGRldl9wbV9vcHMgKnBtID0gZGV2LT5k
cml2ZXIgPyBkZXYtPmRyaXZlci0+cG0NCj4gOiBOVUxMOw0KPiAgCWludCBlcnIgPSAwOw0KPiAg
DQo+IC0JaWYgKHBtICYmIHBtLT5ydW50aW1lX3Jlc3VtZSkgew0KPiAtCQlibGtfcHJlX3J1bnRp
bWVfcmVzdW1lKHNkZXYtPnJlcXVlc3RfcXVldWUpOw0KPiArCWJsa19wcmVfcnVudGltZV9yZXN1
bWUoc2Rldi0+cmVxdWVzdF9xdWV1ZSk7DQo+ICsJaWYgKHBtICYmIHBtLT5ydW50aW1lX3Jlc3Vt
ZSkNCj4gIAkJZXJyID0gcG0tPnJ1bnRpbWVfcmVzdW1lKGRldik7DQo+IC0JCWJsa19wb3N0X3J1
bnRpbWVfcmVzdW1lKHNkZXYtPnJlcXVlc3RfcXVldWUsIGVycik7DQo+IC0JfQ0KPiArCWJsa19w
b3N0X3J1bnRpbWVfcmVzdW1lKHNkZXYtPnJlcXVlc3RfcXVldWUsIGVycik7DQo+ICsNCj4gIAly
ZXR1cm4gZXJyOw0KPiAgfQ0KPiAg
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index e4b7998..459abe1 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -219,13 +219,13 @@  static int sdev_runtime_suspend(struct device *dev)
 	struct scsi_device *sdev = to_scsi_device(dev);
 	int err = 0;
 
-	if (pm && pm->runtime_suspend) {
-		err = blk_pre_runtime_suspend(sdev->request_queue);
-		if (err)
-			return err;
+	err = blk_pre_runtime_suspend(sdev->request_queue);
+	if (err)
+		return err;
+	if (pm && pm->runtime_suspend)
 		err = pm->runtime_suspend(dev);
-		blk_post_runtime_suspend(sdev->request_queue, err);
-	}
+	blk_post_runtime_suspend(sdev->request_queue, err);
+
 	return err;
 }
 
@@ -248,11 +248,11 @@  static int sdev_runtime_resume(struct device *dev)
 	const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
 	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);
-		blk_post_runtime_resume(sdev->request_queue, err);
-	}
+	blk_post_runtime_resume(sdev->request_queue, err);
+
 	return err;
 }