From af41f9e9f44a69a8ab159be7ac4055d7950e68c1 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Thu, 16 Oct 2003 19:47:01 +0530 Subject: [PATCH] [PATCH] fix oops caused when writing to the rescan attribute If an upper layer driver is not loaded, and you write to a device's rescan attribute you will get an oops. The attached patch fixes this by testing if the device's driver variable is set before accessing it. --- drivers/scsi/scsi_scan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 4cc679d9caa44..45cebcc5998ad 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1080,8 +1080,12 @@ struct scsi_device *scsi_add_device(struct Scsi_Host *shost, void scsi_rescan_device(struct device *dev) { - struct scsi_driver *drv = to_scsi_driver(dev->driver); + struct scsi_driver *drv; + + if (!dev->driver) + return; + drv = to_scsi_driver(dev->driver); if (try_module_get(drv->owner)) { if (drv->rescan) drv->rescan(dev); -- 2.53.0