Re: Protecting uvcvideo againt USB device disconnect [Was: Re: Protecting usb_set_interface() against device removal]

From: Alan Stern
Date: Wed Aug 19 2020 - 21:31:26 EST


On Wed, Aug 19, 2020 at 04:08:51PM -0700, Guenter Roeck wrote:

> usb_set_interface() should not be called anymore after uvc_disconnect(),
> or at east I think so (is that documented anywhere ?).

It may be documented somewhere, but basically it goes without saying.

A main feature of the device model design is that drivers get bound to
devices by having their probe routine called, and they get unbound by
having their disconnect routine called. It should go without saying
that once a driver is unbound from a device, it must not communicate
with that device any more.

It might be nice if this requirement could be enforced (say in the USB
core), but doing so is impractical. It would require every I/O request
to include some sort of cookie proving that the caller is authorized to
make the request. That's not how the kernel works; it trusts drivers
to generally do the right thing without constant checking.

Alan Stern