Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mike Christie and committed by
Christoph Hellwig
28072ad5 bcbde52b

+2 -1
+2 -1
drivers/scsi/device_handler/scsi_dh.c
··· 136 136 struct scsi_device_handler *scsi_dh = scsi_dh_data->scsi_dh; 137 137 struct scsi_device *sdev = scsi_dh_data->sdev; 138 138 139 + scsi_dh->detach(sdev); 140 + 139 141 spin_lock_irq(sdev->request_queue->queue_lock); 140 142 sdev->scsi_dh_data = NULL; 141 143 spin_unlock_irq(sdev->request_queue->queue_lock); 142 144 143 - scsi_dh->detach(sdev); 144 145 sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", scsi_dh->name); 145 146 module_put(scsi_dh->module); 146 147 }