diff options
author | Christoph Hellwig <hch@lst.de> | 2015-02-02 08:01:24 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2015-03-19 09:38:43 -0400 |
commit | e27829dc92e549486b8248cdfa53e108abb6acfb (patch) | |
tree | ae421000e744e0d3b766bd2a41468b6eaba052fc | |
parent | 4e5a800c82ec21335349a97cf58d97fbb0d3c98e (diff) |
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>
-rw-r--r-- | drivers/scsi/scsi_scan.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 9c0a520d933c..60aae01caa89 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -1570,16 +1570,15 @@ EXPORT_SYMBOL(scsi_add_device); | |||
1570 | 1570 | ||
1571 | void scsi_rescan_device(struct device *dev) | 1571 | void scsi_rescan_device(struct device *dev) |
1572 | { | 1572 | { |
1573 | if (!dev->driver) | 1573 | device_lock(dev); |
1574 | return; | 1574 | if (dev->driver && try_module_get(dev->driver->owner)) { |
1575 | |||
1576 | if (try_module_get(dev->driver->owner)) { | ||
1577 | struct scsi_driver *drv = to_scsi_driver(dev->driver); | 1575 | struct scsi_driver *drv = to_scsi_driver(dev->driver); |
1578 | 1576 | ||
1579 | if (drv->rescan) | 1577 | if (drv->rescan) |
1580 | drv->rescan(dev); | 1578 | drv->rescan(dev); |
1581 | module_put(dev->driver->owner); | 1579 | module_put(dev->driver->owner); |
1582 | } | 1580 | } |
1581 | device_unlock(dev); | ||
1583 | } | 1582 | } |
1584 | EXPORT_SYMBOL(scsi_rescan_device); | 1583 | EXPORT_SYMBOL(scsi_rescan_device); |
1585 | 1584 | ||