From: Christoph Hellwig Date: Mon, 2 Feb 2015 13:01:24 +0000 (+0100) Subject: scsi: serialize ->rescan against ->remove X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e27829dc92e549486b8248cdfa53e108abb6acfb;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Acked-by: Alan Stern Reviewed-by: Paolo Bonzini Reviewed-by: Hannes Reinecke Signed-off-by: James Bottomley --- 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); 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);