diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2022-12-19 15:10:41 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2022-12-19 15:10:41 +0000 |
commit | ca4d52e1505c4ddf7fbda30c967ec379409708d7 (patch) | |
tree | f97b9cfb5f9830173241cabe369e12f8f7b1e854 /sys/dev | |
parent | 124455ef397b7d7fc2d847db20c0e792069ae454 (diff) |
Invalidate ugen(4) knote lists after device detach
This prevents the kernel from crashing when a ugen(4) device is detached
while kqueue still holds a reference to that device.
Crash reported and fix tested by xavier.s on bugs@.
OK mpi@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/ugen.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index bf82f843e9f..194a39a8792 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugen.c,v 1.116 2022/07/02 08:50:42 visa Exp $ */ +/* $OpenBSD: ugen.c,v 1.117 2022/12/19 15:10:40 visa Exp $ */ /* $NetBSD: ugen.c,v 1.63 2002/11/26 18:49:48 christos Exp $ */ /* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -798,6 +798,10 @@ ugen_detach(struct device *self, int flags) for (endptno = 0; endptno < USB_MAX_ENDPOINTS; endptno++) { if (sc->sc_is_open[endptno]) ugen_do_close(sc, endptno, FREAD|FWRITE); + + /* ugenkqfilter() always uses IN. */ + sce = &sc->sc_endpoints[endptno][IN]; + klist_invalidate(&sce->rsel.si_note); } return (0); } |