scsi: serialize ->rescan against ->remove

Lock the device embedded in the scsi_device to protect against
concurrent calls to ->remove.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
This commit is contained in:
Christoph Hellwig 2015-02-02 14:01:24 +01:00 committed by James Bottomley
parent 4e5a800c82
commit e27829dc92
1 changed files with 3 additions and 4 deletions

View File

@ -1570,16 +1570,15 @@ EXPORT_SYMBOL(scsi_add_device);
void scsi_rescan_device(struct device *dev)
{
if (!dev->driver)
return;
if (try_module_get(dev->driver->owner)) {
device_lock(dev);
if (dev->driver && try_module_get(dev->driver->owner)) {
struct scsi_driver *drv = to_scsi_driver(dev->driver);
if (drv->rescan)
drv->rescan(dev);
module_put(dev->driver->owner);
}
device_unlock(dev);
}
EXPORT_SYMBOL(scsi_rescan_device);