Page MenuHomeFreeBSD

ugen: fix USB_IFACE_DRIVER_ACTIVE after detaching a driver
ClosedPublic

Authored by avg on Feb 18 2024, 2:50 PM.
Tags
None
Referenced Files
F102127191: D43960.id134639.diff
Thu, Nov 7, 11:07 PM
Unknown Object (File)
Sat, Nov 2, 11:27 PM
Unknown Object (File)
Sun, Oct 20, 6:44 PM
Unknown Object (File)
Oct 6 2024, 8:23 PM
Unknown Object (File)
Sep 18 2024, 10:40 PM
Unknown Object (File)
Sep 16 2024, 7:01 AM
Unknown Object (File)
Sep 5 2024, 4:09 PM
Unknown Object (File)
Aug 30 2024, 11:05 AM
Subscribers

Details

Summary

Previosuly, USB_IFACE_DRIVER_ACTIVE would report that the driver is
active even after it detached. That's because a device(9) still
remains.

So, add device_is_alive(9) check for more accurate reporting.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

avg requested review of this revision.Feb 18 2024, 2:50 PM

Seems reasonable to me.

sys/dev/usb/usb_generic.c
2383

Is there a reason not to use device_is_attached()? That seems closer to the spirit of this ioctl, but I'm not very familiar with this area.

This revision is now accepted and ready to land.Feb 18 2024, 2:54 PM
sys/dev/usb/usb_generic.c
2383

It was what I used initially, based on ugen_get_iface_driver.
But then I got a bit worried about concurrent probing and attaching, I decided to err on the side of caution.
Both checks worked equally well in my case.
BTW, the situation was this:

  • connect a USB device
  • see it claimed by uhid driver
  • see that it is impossible to use with a libusb-based application
  • unload uhid module
  • the application still refuses to work because of USB_IFACE_DRIVER_ACTIVE
sys/dev/usb/usb_generic.c
2383

That makes sense, thanks.