I tested, it looks promising:
0. Rebooted on the new GENERIC.MP built, uname -v GENERIC.MP#0 1. Physical plug ugen0 at uhub0 port 7 "INNO TECH USB to Serial" rev 1.10/0.02 addr 3 2. Read tail -f /dev/ugen0.01 3. Physical unplug ugen0 detached 4. Tail reports i/o error as expected tail: /dev/ugen0.01: Input/output error tail: Lost file /dev/ugen0.01: Input/output error 5. ^C No panic occurring. Excellent! Well, thanks you very much for this fix. If more testing is needed, please let me know. Cheers. De : Visa Hankala <[email protected]> À : [email protected] Sujet : Re: panic at klist_remove_locked trigerred by SIGTERM on tail -f /dev/ugen0.01 after unplugging a USB serial interface Date : 18/12/2022 12:49:01 Europe/Paris Copie à : [email protected] On Sat, Dec 17, 2022 at 02:32:03PM +0100, [email protected] wrote: > While doing the following actions: > > 1. Plugging this USB device: > > ugen0 at uhub0 port 7 "INNO TECH USB to Serial" rev 1.10/0.02 addr 2 > > 2. Running (remotely via ssh) > > tail -f /dev/ugen0.01 > > 3. Physically unplugging the USB device > > [kernel notices ugen0 detached] > > 4. ^C in the terminal attached to the `tail -f /dev/ugen0.01` of step 2 > > Panic occurs. > > [...] > > kernel: page fault trap, code x0 > > Stopped at klist_remove_locked.0x53 This indicates that there was a stray knote that referred to the detached device. The following patch might help. Could you test it? Index: dev/usb/ugen.c =================================================================== RCS file: src/sys/dev/usb/ugen.c,v retrieving revision 1.116 diff -u -p -r1.116 ugen.c --- dev/usb/ugen.c 2 Jul 2022 08:50:42 -0000 1.116 +++ dev/usb/ugen.c 18 Dec 2022 11:42:26 -0000 @@ -474,6 +474,8 @@ ugen_do_close(struct ugen_softc *sc, int free(sce->ibuf, M_USBDEV, sce->ibuflen); sce->ibuf = NULL; } + + klist_invalidate(&sce->rsel.si_note); } sc->sc_is_open[endpt] = 0;
