Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: Mike Snitzer <snitzer@redhat.com>
Cc: James Bottomley <James.Bottomley@suse.de>, linux-scsi@vger.kernel.org
Subject: Re: [RESEND][2.6.39-rc PATCH] [SCSI] scsi_dh: fix reference counting in scsi_dh_activate error path
Date: Fri, 08 Apr 2011 17:03:00 -0500	[thread overview]
Message-ID: <4D9F8614.7070208@cs.wisc.edu> (raw)
In-Reply-To: <20110408190536.GA11001@redhat.com>

On 04/08/2011 02:05 PM, Mike Snitzer wrote:
> diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
> index 564e6ec..0119b81 100644
> --- a/drivers/scsi/device_handler/scsi_dh.c
> +++ b/drivers/scsi/device_handler/scsi_dh.c
> @@ -394,12 +394,14 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
>   	unsigned long flags;
>   	struct scsi_device *sdev;
>   	struct scsi_device_handler *scsi_dh = NULL;
> +	struct device *dev = NULL;
>
>   	spin_lock_irqsave(q->queue_lock, flags);
>   	sdev = q->queuedata;
>   	if (sdev&&  sdev->scsi_dh_data)
>   		scsi_dh = sdev->scsi_dh_data->scsi_dh;
> -	if (!scsi_dh || !get_device(&sdev->sdev_gendev) ||
> +	dev = get_device(&sdev->sdev_gendev);
> +	if (!scsi_dh || !dev ||
>   	    sdev->sdev_state == SDEV_CANCEL ||
>   	    sdev->sdev_state == SDEV_DEL)
>   		err = SCSI_DH_NOSYS;
> @@ -410,12 +412,13 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
>   	if (err) {
>   		if (fn)
>   			fn(data, err);
> -		return err;
> +		goto out;
>   	}
>
>   	if (scsi_dh->activate)
>   		err = scsi_dh->activate(sdev, fn, data);
> -	put_device(&sdev->sdev_gendev);
> +out:
> +	put_device(dev);
>   	return err;
>   }
>   EXPORT_SYMBOL_GPL(scsi_dh_activate);
>

Looks correct to me.

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

      reply	other threads:[~2011-04-08 22:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08 19:05 [RESEND][2.6.39-rc PATCH] [SCSI] scsi_dh: fix reference counting in scsi_dh_activate error path Mike Snitzer
2011-04-08 22:03 ` Mike Christie [this message]

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=4D9F8614.7070208@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=James.Bottomley@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=snitzer@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox