ugen: fix USB_IFACE_DRIVER_ACTIVE after detaching a driver

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.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43960
This commit is contained in:
Andriy Gapon 2024-02-19 12:44:00 +02:00
parent b7dce5b8e9
commit 8f374fa528

View file

@ -2377,12 +2377,10 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags)
break;
case USB_IFACE_DRIVER_ACTIVE:
n = *u.pint & 0xFF;
iface = usbd_get_iface(f->udev, n);
if (iface && iface->subdev)
if (iface != NULL && iface->subdev != NULL &&
device_is_alive(iface->subdev))
error = 0;
else
error = ENXIO;