All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Bart Van Assche <bvanassche@acm.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	James Bottomley <jbottomley@parallels.com>,
	Jens Axboe <axboe@kernel.dk>, Joe Lawrence <jdl1291@gmail.com>,
	Jun'ichi Nomura <j-nomura@ce.jp.nec.com>,
	Muthukumar Ratty <muthur@gmail.com>,
	Stefan Richter <stefanr@s5r6.in-berlin.de>,
	Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 3/5] scsi: Avoid dangling pointer in scsi_requeue_command()
Date: Fri, 29 Jun 2012 11:06:21 -0500	[thread overview]
Message-ID: <4FEDD27D.4010803@cs.wisc.edu> (raw)
In-Reply-To: <4FEDCB02.6070600@acm.org>

On 06/29/2012 10:34 AM, Bart Van Assche wrote:
> Reported-by: Mike Christie <michaelc@cs.wisc.edu>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: James Bottomley <JBottomley@parallels.com>
> Cc: <stable@kernel.org>
> ---
>   drivers/scsi/scsi_lib.c |    9 +++++++++
>   1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 7ebe167..af6357a 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -479,15 +479,24 @@ void scsi_requeue_run_queue(struct work_struct *work)
>    */
>   static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
>   {
> +	struct scsi_device *sdev = cmd->device;
>   	struct request *req = cmd->request;
>   	unsigned long flags;
>
> +	/*
> +	 * We need to hold a reference on the device to avoid that the queue
> +	 * gets killed after the unlock and before scsi_run_queue is invoked.
> +	 */
> +	get_device(&sdev->sdev_gendev);
> +
>   	spin_lock_irqsave(q->queue_lock, flags);
>   	scsi_unprep_request(req);
>   	blk_requeue_request(q, req);
>   	spin_unlock_irqrestore(q->queue_lock, flags);
>
>   	scsi_run_queue(q);
> +
> +	put_device(&sdev->sdev_gendev);
>   }
>
>   void scsi_next_command(struct scsi_cmnd *cmd)
>

Looks ok to me

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

  reply	other threads:[~2012-06-29 16:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29 15:30 [PATCH 0/4 v10] SCSI device removal fixes Bart Van Assche
2012-06-29 15:31 ` [PATCH 1/5] block: Fix blk_execute_rq_nowait() dead queue handling Bart Van Assche
2012-06-29 15:33 ` [PATCH 2/5] scsi: Fix device removal NULL pointer dereference Bart Van Assche
2012-06-29 15:34 ` [PATCH 3/5] scsi: Avoid dangling pointer in scsi_requeue_command() Bart Van Assche
2012-06-29 16:06   ` Mike Christie [this message]
2012-06-29 16:48   ` Tejun Heo
2012-06-29 15:35 ` [PATCH 4/5] scsi: Change return type of scsi_queue_insert() into void Bart Van Assche
2012-06-29 15:36 ` [PATCH 5/5] scsi: Stop accepting SCSI requests before removing a device Bart Van Assche

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=4FEDD27D.4010803@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=j-nomura@ce.jp.nec.com \
    --cc=jbottomley@parallels.com \
    --cc=jdl1291@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=muthur@gmail.com \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=tj@kernel.org \
    /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.