All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: Ken Xue <Ken.Xue@amd.com>
Cc: stern@rowland.harvard.edu, Shane.Huang@amd.com,
	Xiangliang.Yu@amd.com, aaron.lu@intel.com,
	linux-scsi@vger.kernel.org, JBottomley@Odin.com,
	SPG_Linux_Kernel@amd.com
Subject: Re: [PATCH]SCSI:Refine the way to fix NULL pointer dereference in runtime PM
Date: Wed, 9 Sep 2015 16:30:59 +0800	[thread overview]
Message-ID: <20150909083058.GA6425@hr-slim.amd.com> (raw)
In-Reply-To: <1441782131.5845.73.camel@kxue-X58A-UD3R>

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

  reply	other threads:[~2015-09-09 10:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150909083058.GA6425@hr-slim.amd.com \
    --to=ray.huang@amd.com \
    --cc=JBottomley@Odin.com \
    --cc=Ken.Xue@amd.com \
    --cc=SPG_Linux_Kernel@amd.com \
    --cc=Shane.Huang@amd.com \
    --cc=Xiangliang.Yu@amd.com \
    --cc=aaron.lu@intel.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.