All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM
@ 2015-09-09  7:02 Ken Xue
  2015-09-09  8:30 ` Huang Rui
  2015-09-10  2:23   ` Ken Xue
  0 siblings, 2 replies; 9+ messages in thread
From: Ken Xue @ 2015-09-09  7:02 UTC (permalink / raw
  To: stern
  Cc: Shane.Huang, Xiangliang.Yu, aaron.lu, linux-scsi, JBottomley,
	SPG_Linux_Kernel

>From 844ebfcecad7ddaf7206e0474c600b0146b4ef21 Mon Sep 17 00:00:00 2001
From: Ken Xue <Ken.Xue@amd.com>
Date: Wed, 9 Sep 2015 14:55:21 +0800
Subject: [PATCH] SCSI:Refine the way to fix NULL pointer dereference in
 runtime PM

There was a patch about Bugzilla #101371. That patch introduced a
possibility that can not call blk_{pre|post}_runtime_suspend and
blk_{pre|post}_runtime_resume in pairs.

Signed-off-by: Ken Xue <Ken.Xue@amd.com>
---
 block/blk-core.c       | 12 ++++++++++++
 drivers/scsi/scsi_pm.c | 20 ++++++++++----------
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 60912e9..a07ab18 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3280,6 +3280,9 @@ int blk_pre_runtime_suspend(struct request_queue *q)
 {
 	int ret = 0;
 
+	if (!q->dev)
+		return ret;
+
 	spin_lock_irq(q->queue_lock);
 	if (q->nr_pending) {
 		ret = -EBUSY;
@@ -3307,6 +3310,9 @@ EXPORT_SYMBOL(blk_pre_runtime_suspend);
  */
 void blk_post_runtime_suspend(struct request_queue *q, int err)
 {
+	if (!q->dev)
+		return;
+
 	spin_lock_irq(q->queue_lock);
 	if (!err) {
 		q->rpm_status = RPM_SUSPENDED;
@@ -3331,6 +3337,9 @@ EXPORT_SYMBOL(blk_post_runtime_suspend);
  */
 void blk_pre_runtime_resume(struct request_queue *q)
 {
+	if (!q->dev)
+		return;
+
 	spin_lock_irq(q->queue_lock);
 	q->rpm_status = RPM_RESUMING;
 	spin_unlock_irq(q->queue_lock);
@@ -3353,6 +3362,9 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
  */
 void blk_post_runtime_resume(struct request_queue *q, int err)
 {
+	if (!q->dev)
+		return;
+
 	spin_lock_irq(q->queue_lock);
 	if (!err) {
 		q->rpm_status = RPM_ACTIVE;
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;
 }
 
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM
  2015-09-09  7:02 [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM Ken Xue
@ 2015-09-09  8:30 ` Huang Rui
  2015-09-09  8:40   ` Ken Xue
  2015-09-10  2:23   ` Ken Xue
  1 sibling, 1 reply; 9+ messages in thread
From: Huang Rui @ 2015-09-09  8:30 UTC (permalink / raw
  To: Ken Xue
  Cc: stern, Shane.Huang, Xiangliang.Yu, aaron.lu, linux-scsi,
	JBottomley, SPG_Linux_Kernel

On Wed, Sep 09, 2015 at 03:02:11PM +0800, Ken Xue wrote:
> From 844ebfcecad7ddaf7206e0474c600b0146b4ef21 Mon Sep 17 00:00:00 2001
> From: Ken Xue <Ken.Xue@amd.com>
> Date: Wed, 9 Sep 2015 14:55:21 +0800
> Subject: [PATCH] SCSI:Refine the way to fix NULL pointer dereference in
>  runtime PM
> 
> There was a patch about Bugzilla #101371.

Which Bugzilla? I guess you should put a link or oops message of NULL
pointer dereference here. Then other guys can know detail infomation
of this fix.

Thanks,
Rui

> That patch introduced a possibility that can not call
> blk_{pre|post}_runtime_suspend and blk_{pre|post}_runtime_resume in
> pairs.
> 
> Signed-off-by: Ken Xue <Ken.Xue@amd.com>
> ---
>  block/blk-core.c       | 12 ++++++++++++
>  drivers/scsi/scsi_pm.c | 20 ++++++++++----------
>  2 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 60912e9..a07ab18 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -3280,6 +3280,9 @@ int blk_pre_runtime_suspend(struct request_queue *q)
>  {
>  	int ret = 0;
>  
> +	if (!q->dev)
> +		return ret;
> +
>  	spin_lock_irq(q->queue_lock);
>  	if (q->nr_pending) {
>  		ret = -EBUSY;
> @@ -3307,6 +3310,9 @@ EXPORT_SYMBOL(blk_pre_runtime_suspend);
>   */
>  void blk_post_runtime_suspend(struct request_queue *q, int err)
>  {
> +	if (!q->dev)
> +		return;
> +
>  	spin_lock_irq(q->queue_lock);
>  	if (!err) {
>  		q->rpm_status = RPM_SUSPENDED;
> @@ -3331,6 +3337,9 @@ EXPORT_SYMBOL(blk_post_runtime_suspend);
>   */
>  void blk_pre_runtime_resume(struct request_queue *q)
>  {
> +	if (!q->dev)
> +		return;
> +
>  	spin_lock_irq(q->queue_lock);
>  	q->rpm_status = RPM_RESUMING;
>  	spin_unlock_irq(q->queue_lock);
> @@ -3353,6 +3362,9 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
>   */
>  void blk_post_runtime_resume(struct request_queue *q, int err)
>  {
> +	if (!q->dev)
> +		return;
> +
>  	spin_lock_irq(q->queue_lock);
>  	if (!err) {
>  		q->rpm_status = RPM_ACTIVE;
> 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;
>  }
>  
> -- 
> 1.9.1
> 
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM
  2015-09-09  8:30 ` Huang Rui
@ 2015-09-09  8:40   ` Ken Xue
  2015-09-09  9:33     ` Huang Rui
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Xue @ 2015-09-09  8:40 UTC (permalink / raw
  To: Huang Rui
  Cc: stern, Shane.Huang, Xiangliang.Yu, aaron.lu, linux-scsi,
	JBottomley, SPG_Linux_Kernel

On Wed, 2015-09-09 at 16:30 +0800, Huang Rui wrote:
> On Wed, Sep 09, 2015 at 03:02:11PM +0800, Ken Xue wrote:
> > From 844ebfcecad7ddaf7206e0474c600b0146b4ef21 Mon Sep 17 00:00:00 2001
> > From: Ken Xue <Ken.Xue@amd.com>
> > Date: Wed, 9 Sep 2015 14:55:21 +0800
> > Subject: [PATCH] SCSI:Refine the way to fix NULL pointer dereference in
> >  runtime PM
> > 
> > There was a patch about Bugzilla #101371.
> 
> Which Bugzilla? I guess you should put a link or oops message of NULL
> pointer dereference here. Then other guys can know detail infomation
> of this fix.
> 
You can find out previous patch with commit ID 49718f.
You also can find log with below link
https://bugzilla.kernel.org/show_bug.cgi?id=101371




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM
  2015-09-09  8:40   ` Ken Xue
@ 2015-09-09  9:33     ` Huang Rui
  2015-09-09 15:41       ` Alan Stern
  0 siblings, 1 reply; 9+ messages in thread
From: Huang Rui @ 2015-09-09  9:33 UTC (permalink / raw
  To: Ken Xue, Alan Stern
  Cc: Huang, Shane, Yu, Xiangliang, aaron.lu@intel.com,
	linux-scsi@vger.kernel.org, JBottomley@Odin.com, SPG_Linux_Kernel

On Wed, Sep 09, 2015 at 04:40:07PM +0800, Ken Xue wrote:
> On Wed, 2015-09-09 at 16:30 +0800, Huang Rui wrote:
> > On Wed, Sep 09, 2015 at 03:02:11PM +0800, Ken Xue wrote:
> > > From 844ebfcecad7ddaf7206e0474c600b0146b4ef21 Mon Sep 17 00:00:00 2001
> > > From: Ken Xue <Ken.Xue@amd.com>
> > > Date: Wed, 9 Sep 2015 14:55:21 +0800
> > > Subject: [PATCH] SCSI:Refine the way to fix NULL pointer dereference in
> > >  runtime PM
> > > 
> > > There was a patch about Bugzilla #101371.
> > 
> > Which Bugzilla? I guess you should put a link or oops message of NULL
> > pointer dereference here. Then other guys can know detail infomation
> > of this fix.
> > 
> You can find out previous patch with commit ID 49718f.
> You also can find log with below link
> https://bugzilla.kernel.org/show_bug.cgi?id=101371
> 

I see. So maybe we would better mark the commit ID. :)

Alan, could you please take a look?

Thanks,
Rui

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM
  2015-09-09  9:33     ` Huang Rui
@ 2015-09-09 15:41       ` Alan Stern
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Stern @ 2015-09-09 15:41 UTC (permalink / raw
  To: Huang Rui
  Cc: Ken Xue, Huang, Shane, Yu, Xiangliang, aaron.lu@intel.com,
	linux-scsi@vger.kernel.org, JBottomley@Odin.com, SPG_Linux_Kernel

On Wed, 9 Sep 2015, Huang Rui wrote:

> On Wed, Sep 09, 2015 at 04:40:07PM +0800, Ken Xue wrote:
> > On Wed, 2015-09-09 at 16:30 +0800, Huang Rui wrote:
> > > On Wed, Sep 09, 2015 at 03:02:11PM +0800, Ken Xue wrote:
> > > > From 844ebfcecad7ddaf7206e0474c600b0146b4ef21 Mon Sep 17 00:00:00 2001
> > > > From: Ken Xue <Ken.Xue@amd.com>
> > > > Date: Wed, 9 Sep 2015 14:55:21 +0800
> > > > Subject: [PATCH] SCSI:Refine the way to fix NULL pointer dereference in
> > > >  runtime PM
> > > > 
> > > > There was a patch about Bugzilla #101371.
> > > 
> > > Which Bugzilla? I guess you should put a link or oops message of NULL
> > > pointer dereference here. Then other guys can know detail infomation
> > > of this fix.
> > > 
> > You can find out previous patch with commit ID 49718f.
> > You also can find log with below link
> > https://bugzilla.kernel.org/show_bug.cgi?id=101371
> > 
> 
> I see. So maybe we would better mark the commit ID. :)
> 
> Alan, could you please take a look?

Yes.

Ken, your fix was good but the description was bad.  The description 
did not explain what the problem was or how you were going to fix it.

In fact, this change should be split up into two patches.  The first 
patch should simply revert commit 49718f0fb8c9 ("SCSI: Fix NULL pointer 
dereference in runtime PM") and the description should explain why that 
commit didn't work properly for the sr driver.

The second patch should make the new changes to the block core.  The 
description should explain why the changes are needed, and it can 
reference Bugzilla #101371.

Both patches should be tagged for the -stable kernels.  When you have 
done all that, you can add:

Acked-by: Alan Stern <stern@rowland.harvard.edu>

to both patches.

Alan Stern


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2]Revert "SCSI: Fix NULL pointer dereference in runtime PM"
  2015-09-09  7:02 [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM Ken Xue
@ 2015-09-10  2:23   ` Ken Xue
  2015-09-10  2:23   ` Ken Xue
  1 sibling, 0 replies; 9+ messages in thread
From: Ken Xue @ 2015-09-10  2:23 UTC (permalink / raw
  To: stern
  Cc: Shane.Huang, Xiangliang.Yu, aaron.lu, linux-scsi, JBottomley,
	SPG_Linux_Kernel, stable

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(-)

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;
 }
 
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 1/2]Revert "SCSI: Fix NULL pointer dereference in runtime PM"
@ 2015-09-10  2:23   ` Ken Xue
  0 siblings, 0 replies; 9+ messages in thread
From: Ken Xue @ 2015-09-10  2:23 UTC (permalink / raw
  To: stern
  Cc: Shane.Huang, Xiangliang.Yu, aaron.lu, linux-scsi, JBottomley,
	SPG_Linux_Kernel, stable

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(-)

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;
 }
 
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2]Revert "SCSI: Fix NULL pointer dereference in runtime PM"
  2015-09-10  2:23   ` Ken Xue
@ 2015-11-27  3:01     ` Xue, Ken
  -1 siblings, 0 replies; 9+ messages in thread
From: Xue, Ken @ 2015-11-27  3:01 UTC (permalink / raw
  To: linux-kernel@vger.kernel.org, mlin@kernel.org,
	stern@rowland.harvard.edu
  Cc: linux-scsi@vger.kernel.org, Huang, Shane, SPG_Linux_Kernel,
	aaron.lu@intel.com, stable@vger.kernel.org, JBottomley@Odin.com,
	Yu, Xiangliang

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2501 bytes --]

On å››, 2015-09-10 at 10:23 +0800, Ken Xue wrote:

Can someone help to apply this patch series? Thanks.
http://marc.info/?l=linux-scsi&m=144185206825609&w=2
http://marc.info/?l=linux-scsi&m=144185208525611&w=2 

> 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(-)
> 
> 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;
>  }
>  ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2]Revert "SCSI: Fix NULL pointer dereference in runtime PM"
@ 2015-11-27  3:01     ` Xue, Ken
  0 siblings, 0 replies; 9+ messages in thread
From: Xue, Ken @ 2015-11-27  3:01 UTC (permalink / raw
  To: linux-kernel@vger.kernel.org, mlin@kernel.org,
	stern@rowland.harvard.edu
  Cc: linux-scsi@vger.kernel.org, Huang, Shane, SPG_Linux_Kernel,
	aaron.lu@intel.com, stable@vger.kernel.org, JBottomley@Odin.com,
	Yu, Xiangliang

On 四, 2015-09-10 at 10:23 +0800, Ken Xue wrote:

Can someone help to apply this patch series? Thanks.
http://marc.info/?l=linux-scsi&m=144185206825609&w=2
http://marc.info/?l=linux-scsi&m=144185208525611&w=2 

> 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(-)
> 
> 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;
>  }
>  

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-27  3:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-09  7:02 [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM Ken Xue
2015-09-09  8:30 ` Huang Rui
2015-09-09  8:40   ` Ken Xue
2015-09-09  9:33     ` Huang Rui
2015-09-09 15:41       ` Alan Stern
2015-09-10  2:23 ` [PATCH 1/2]Revert "SCSI: Fix NULL pointer dereference in runtime PM" Ken Xue
2015-09-10  2:23   ` Ken Xue
2015-11-27  3:01   ` Xue, Ken
2015-11-27  3:01     ` Xue, Ken

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.