Re: [linux-usb-devel] BUG when removing USB flash drive

Alan Stern
2004-05-14T15:12:35Z

On Thu, 13 May 2004, Mike Anderson wrote:

> The LLDD queuecommand should not be called after the return of
> scsi_remove_host (unless we have a bug). The LLDD should not free its
> resources until the release function is called on the struct device
> passed in during the scsi_add_host call.

Ah. We have a problem here, because usb-storage doesn't own that struct
device. It is owned by the USB core, and usb-storage has no way to know
when its release function has been called.

Even worse, the release function may never be called at all. The device
itself may still exist and be attached to the system even though the
usb-storage driver has been unbound from it.

There must be many other LLDDs with the same problem. Any driver that
manages a PCI host controller, for example. The struct device it receives
from the PCI layer isn't owned by the LLDD, yet that's what it must pass
to scsi_add_host().

How should we handle this?

Alan Stern