Re: [RESEND][2.6.39-rc PATCH] [SCSI] scsi_dh: fix reference counting in scsi_dh_activate error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux