During an async scan the driver shost->hostt structures are used, that may cause issues when the driver is removed at that time. As protection take the module reference. Signed-off-by: Tomas Henzl <thenzl@xxxxxxxxxx> --- drivers/scsi/scsi_scan.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index f2437a757..c9cc0862c 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1825,6 +1825,8 @@ static void do_scan_async(void *_data, async_cookie_t c) do_scsi_scan_host(shost); scsi_finish_async_scan(data); + + module_put(shost->hostt->module); } /** @@ -1848,6 +1850,12 @@ void scsi_scan_host(struct Scsi_Host *shost) return; } + /* protection against surprise driver removal + * module_put is called from do_scan_async + */ + if (!try_module_get(shost->hostt->module)) + return; + /* register with the async subsystem so wait_for_device_probe() * will flush this work */ -- 2.25.4