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
F121043879: D43960.id134639.diff
Mon, Jun 23, 4:26 AM
Unknown Object (File)
Fri, Jun 13, 2:33 PM
Unknown Object (File)
Thu, Jun 12, 2:32 PM
Unknown Object (File)
Mon, Jun 9, 3:16 AM
Unknown Object (File)
May 22 2025, 12:26 PM
Unknown Object (File)
May 8 2025, 9:59 AM
Unknown Object (File)
Apr 29 2025, 3:47 PM
Unknown Object (File)
Apr 24 2025, 8:49 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.