scsi: fix device handler detach oops

This fixes a regression caused by commit 1d5203 ("scsi: handle more device
handler setup/teardown in common code").

The bug is that the alua detach() callout will try to access the
sddev->scsi_dh_data, but we have already set it to NULL. This patch
moves the clearing of that field to after detach() is called.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Mike Christie 2015-01-28 03:46:53 -06:00 committed by Christoph Hellwig
parent bcbde52b14
commit 28072ad50c
1 changed files with 2 additions and 1 deletions

View File

@ -136,11 +136,12 @@ static void __detach_handler (struct kref *kref)
struct scsi_device_handler *scsi_dh = scsi_dh_data->scsi_dh; struct scsi_device_handler *scsi_dh = scsi_dh_data->scsi_dh;
struct scsi_device *sdev = scsi_dh_data->sdev; struct scsi_device *sdev = scsi_dh_data->sdev;
scsi_dh->detach(sdev);
spin_lock_irq(sdev->request_queue->queue_lock); spin_lock_irq(sdev->request_queue->queue_lock);
sdev->scsi_dh_data = NULL; sdev->scsi_dh_data = NULL;
spin_unlock_irq(sdev->request_queue->queue_lock); spin_unlock_irq(sdev->request_queue->queue_lock);
scsi_dh->detach(sdev);
sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", scsi_dh->name); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", scsi_dh->name);
module_put(scsi_dh->module); module_put(scsi_dh->module);
} }