Re: Suggestion for aiding debugging of host removal

Christoph Hellwig
2003-12-10T15:15:05Z

On Wed, Dec 10, 2003 at 10:02:22AM -0500, Alan Stern wrote:
> Mike:
>
> I've got a question about host removal. Once scsi_remove_host() has
> returned, the host driver's module is free to unload from memory (assuming
> the module's reference count is 0, which it normally is). Hence it is a
> mistake to access the host template in any way after that time.
>
> But it looks like scsi_host_dev_release() can be called after
> scsi_remove_host() has returned, and it uses shost->hostt. There may be
> other uses as well.
>
> Would it help flush out such illegal accesses if at some appropriate point
> shost->hostt was set to NULL, maybe near the end of scsi_remove_host()?

In fact that's a bug in the current scsi_host lifetime handling - before
the driver can leave it's upper layer ->remove function we need to wait
to the host refcount to become zero, similar to what free_netdev does.

I'll see whether I can come up with a fix.