--- - branch: MAIN date: Mon Mar 28 12:42:45 UTC 2022 files: - new: '1.120' old: '1.119' path: src/sys/dev/usb/uhid.c pathrev: src/sys/dev/usb/uhid.c@1.120 type: modified id: 20220328T124245Z.4ead6e12fe66f99f21f414ce609e0c37bc7224bb log: | uhid(4): Use d_cfdriver/devtounit/cancel to avoid open/detach races. - Split uhidclose into separate uhidcancel and uhidclose parts. uhidcancel interrupts pending I/O operations (open, read, write, ioctl, &c.); uhidclose doesn't run until all I/O operations are done. - Handle case where, owing to revoke(2), uhidcancel/uhidclose run concurrently with a uhidopen that hasn't yet noticed that there isn't actually a device. - Handle case where, owing to revoke(2), uhidread might be cancelled by mere revoke, not by detach, so it has to wake up when the device is closing, not (just) when dying (but dying will lead to closing so no need to check for dying). - Omit needless reference-counting goo. vdevgone takes care of this for us by cancelling all I/O operations with uhidcancel, waiting for I/O operations to drain, closing the device, and waiting until it is closed if that is already happening concurrently. - Name the closed/changing/open states rather than using 0/1/2. - Omit needless sc_dying. module: src subject: 'CVS commit: src/sys/dev/usb' unixtime: '1648471365' user: riastradh