mirror of https://gitee.com/openkylin/linux.git
[SCSI] scsi_dh: fix reference counting in scsi_dh_activate error path
Commit db422318cb
([SCSI] scsi_dh:
propagate SCSI device deletion) introduced a regression where the device
reference is not dropped prior to scsi_dh_activate's early return from
the error path.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@kernel.org # 2.6.38
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
This commit is contained in:
parent
a1f74ae82d
commit
0b8393578c
|
@ -394,12 +394,14 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct scsi_device *sdev;
|
struct scsi_device *sdev;
|
||||||
struct scsi_device_handler *scsi_dh = NULL;
|
struct scsi_device_handler *scsi_dh = NULL;
|
||||||
|
struct device *dev = NULL;
|
||||||
|
|
||||||
spin_lock_irqsave(q->queue_lock, flags);
|
spin_lock_irqsave(q->queue_lock, flags);
|
||||||
sdev = q->queuedata;
|
sdev = q->queuedata;
|
||||||
if (sdev && sdev->scsi_dh_data)
|
if (sdev && sdev->scsi_dh_data)
|
||||||
scsi_dh = sdev->scsi_dh_data->scsi_dh;
|
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_CANCEL ||
|
||||||
sdev->sdev_state == SDEV_DEL)
|
sdev->sdev_state == SDEV_DEL)
|
||||||
err = SCSI_DH_NOSYS;
|
err = SCSI_DH_NOSYS;
|
||||||
|
@ -410,12 +412,13 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
|
||||||
if (err) {
|
if (err) {
|
||||||
if (fn)
|
if (fn)
|
||||||
fn(data, err);
|
fn(data, err);
|
||||||
return err;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scsi_dh->activate)
|
if (scsi_dh->activate)
|
||||||
err = scsi_dh->activate(sdev, fn, data);
|
err = scsi_dh->activate(sdev, fn, data);
|
||||||
put_device(&sdev->sdev_gendev);
|
out:
|
||||||
|
put_device(dev);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(scsi_dh_activate);
|
EXPORT_SYMBOL_GPL(scsi_dh_activate);
|
||||||
|
|
Loading…
Reference in New Issue