On Mon, 2020-09-07 at 17:47 +0200, Tomas Henzl wrote: > 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. Can I just ask what issues? Today, our module model is that scsi_device_get() bumps the module refcount and therefore makes the module ineligible to be removed. scsi_host_get() doesn't do this because the way the host model is supposed to be coded, we can call remove at any time but the module won't get freed until the last put of the host. I can see we have a potential problem with scsi_forget_host() racing with the async scan thread ... is that what you see? What's supposed to happen is that scsi_device_get() starts failing as soon as the module begins it's exit routine, so if a scan is in progress, it can't add any new devices ... in theory this means that the list is stable for scsi_forget_host(), so knowing how that assumption is breaking would be useful. James