From patchwork Tue Dec 1 06:45:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Xue X-Patchwork-Id: 7733211 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4EDFEBEEE1 for ; Tue, 1 Dec 2015 07:07:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 75529206AC for ; Tue, 1 Dec 2015 07:07:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 664B2206AB for ; Tue, 1 Dec 2015 07:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755174AbbLAHGp (ORCPT ); Tue, 1 Dec 2015 02:06:45 -0500 Received: from mail-bn1on0066.outbound.protection.outlook.com ([157.56.110.66]:55568 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755165AbbLAHGn (ORCPT ); Tue, 1 Dec 2015 02:06:43 -0500 X-Greylist: delayed 942 seconds by postgrey-1.27 at vger.kernel.org; Tue, 01 Dec 2015 02:06:42 EST Received: from CY1PR12CA0020.namprd12.prod.outlook.com (10.160.137.30) by SN1PR12MB0861.namprd12.prod.outlook.com (10.164.27.11) with Microsoft SMTP Server (TLS) id 15.1.331.20; Tue, 1 Dec 2015 06:50:57 +0000 Received: from BY2NAM03FT016.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::205) by CY1PR12CA0020.outlook.office365.com (2a01:111:e400:4c1f::30) with Microsoft SMTP Server (TLS) id 15.1.331.20 via Frontend Transport; Tue, 1 Dec 2015 06:50:58 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; canonical.com; dkim=none (message not signed) header.d=none; canonical.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp02.amd.com (165.204.84.222) by BY2NAM03FT016.mail.protection.outlook.com (10.152.84.215) with Microsoft SMTP Server id 15.1.346.13 via Frontend Transport; Tue, 1 Dec 2015 06:50:57 +0000 X-WSS-ID: 0NYO30U-08-HRP-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 23F1CD1A35E; Tue, 1 Dec 2015 01:50:53 -0500 (EST) Received: from SATLEXDAG06.amd.com (10.181.40.13) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 1 Dec 2015 00:51:08 -0600 Received: from SCYBEXDAG04.amd.com (10.34.11.14) by satlexdag06.amd.com (10.181.40.13) with Microsoft SMTP Server (TLS) id 14.3.266.1; Tue, 1 Dec 2015 01:50:55 -0500 Received: from [10.237.74.14] (10.237.74.14) by SCYBEXDAG04.amd.com (10.34.11.14) with Microsoft SMTP Server id 14.3.266.1; Tue, 1 Dec 2015 14:50:49 +0800 Message-ID: <1448952323.3603.17.camel@kxue-X58A-UD3R> Subject: [PATCH 1/2]Revert "SCSI: Fix NULL pointer dereference in runtime PM" From: Ken Xue To: , , , CC: , , , , , Date: Tue, 1 Dec 2015 14:45:23 +0800 X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(209900001)(199003)(189002)(97736004)(101416001)(5001770100001)(33716001)(77096005)(15975445007)(1220700001)(586003)(103116003)(1096002)(87936001)(15395725005)(23676002)(5820100001)(47776003)(230700001)(229853001)(189998001)(106466001)(19580395003)(50986999)(105586002)(50226001)(19580405001)(2201001)(50466002)(86362001)(575784001)(5008740100001)(33646002)(92566002)(99106002)(3940600001)(6606295002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0861; H:atltwp02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0861; 2:a2Xr/6RPvbNVwSLPuPB41r1dx3YtsLQzDiiPtcJuVVQKSjDppS5XBFt/GyRaPvWn9t132AlXgG1WaXb2X11ZUUhUIEFlcDTgICeJNCnWRU5bHzo5Q0xYfO5tEwNZoXXi+Zy7wxzAEuGXhmAFFKj6TA==; 3:j2u4N+gmNNnFMDfRRznjg9q2gNrnFmJH3ITpPFgE+XgcoV7bd3DEuvg2uKXqxO05xEI8ydBAY/GlxzXTUVn5jdhxImv9uM9rbmOVfsOKOGkYFOZeuOpxQwW3wlSWiWzOVDb+kCCan4jPO7hsgEM6U1YDXkfzRefqwJOLrFmaXC/p1psSUe+jIjmcQxw8+g+e0bdfmB5OiUY4yqU+BCKenzGYMVFBlxXqGXsK6OyCMKM=; 25:2/ZyI82hbxIwNgjluN9ONqm8yjxzpPup6FZvO1R1YHesYLt4a0IeIXTHcrzhydBMWJL5SjgzBTydqmjeZDYL7uKF5Taxc0XWRATppHAOeLeGDdi0ViZjIrhtNoegWuAqI2QqdtAMt+jg55mpj5QkL+bRnu0CbFM+c1Ztmb4Kin8tA4DI/dyMZsuCvT6fFX4IJ4ejp1//L5LWFeU9qyapR0dk1lY0WLbJzCj5zR6Wnflb7PCeeMc4UWsBuaN8DfElGs2VVDwMf3uPtI6NT8QLDg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0861; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0861; 20:Y8laqd94NzVHmAOLlqUDdk9Sp6WkOkFYsVotEAoTyiQirM+Bl8WGdVdmzLECB52lYfpt0s0NUkouGfM/GOcpabQb/ke0GfdiOBh0hrbnBQwHp6KXJ/E4ZTuzrJMMX/bLdQ+1k0Oew1S5XGG5+chzfI2H9vkWkJHF9hd12eLEwWW8xieY7UM2V8jv+9cTgFMc8xstb5Nqe+CsPv8pzk681iTaPoSRJw/QMQkWfWVxrUIt3ZOp9e3B3La/T26EyV37AlPTt7VgRrXZ3caPKBb1J2FxwR5U5yEw/Wo0jV/R3DW+VkOGCSALf7NiX6E7zqnEyvUqU3dM0BUynEbDsKhF+QwUrl7HlDnF5QT853ddlqpNj/kt3boJAPpYleZFCkXG2v1U6XOfUMUEQI7pGok/y31WTzrfBKx9Zag5U15E9wr4AdBhqQxhXm6TCWmtbhT9P5uRnUS+xFl5ENF9B62YM1LZZP8UVREofrNMkVy2DnuS/aK3OtHsOQ+qrUSXEeXr X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:SN1PR12MB0861; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0861; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0861; 4:LCf0f0oD+s8v6GYUqKdq1Ogd/Va5xhGJvWZDyhv8DCRVRlZlZ7svP2NfcENUry97E58mBliTJ/dQu1T7+S8CSTUdisOq0VbZ7o09eIkX+3BkHM1WKBaNqGXznfimE+t/44w3FaGh66/1nUe+Y/2S78Y4eRqrGp5SMSS/5UQuA4gMpyf/AoHGJI5tqoW9/TRbz4xxRupbBtZy8nPwjRosH8dlmRjf0sMKx6K+WcCc2Il5MVqowqIwVuOxbO6YXSxtTitS4x75fC/wDKnCUZ+Wr4lVgvd7yKJu4CqIoT0sHVTgBRbSFg4v/xOZ4KjHmL6ArNhVjL6eCWxUwOKdvWx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vtCVmv2dSDVeZYtKQKN/lkBpkIceBrPd6fg==; 24:HY21a0G1YzGTVYfv7WfXWzolVqVjC55rP6VQQc8UMktR361QJ/FpNGqVm4ba7WfjR3ovt9yHDPUlu5ihIZ+NMBeoOgBENzpFzp7QWSL2TrQ=; 20:Mz16bkrP4Fm80GvIGRwmhB97gnGS1U9mqIVVDLlpdOos+4hiPL9a2I0siuaq958a1OdSyM9SuJUBQ4wD5M0h4Vc+7sJ+sMTPE9b5/Sp5P7dEJR43CgigetIifb2mRJVOomFIh2o9n7fGwN6K1+OBOGEHOdRDTUZa9uXSmjPgK/SPKZPg3297nrbrrF1l2c/oC4ptTp1GTfMarnlsisFYv6q037Mp9LE3+lxYWYlGqf8XiXCBjYfzUa9cIKdT1l0Q SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2015 06:50:57.0777 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0861 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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=2 Signed-off-by: Ken Xue Acked-by: Alan Stern Cc: Xiangliang Yu Cc: James E.J. Bottomley Cc: Jens Axboe Cc: Michael Terry Cc: stable@vger.kernel.org --- drivers/scsi/scsi_pm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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; }