diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-01-16 09:59:27 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-01-16 09:59:27 +0000 |
commit | 0058a212530c8789019144173dc45d5fd4279237 (patch) | |
tree | 6c65045263c1f3c65aa5e92ec152bf9708b71e23 /sys/dev/usb | |
parent | 142be4974317e476546305deba2edba40f7fa04a (diff) |
Free data structures after closing the pseudo-device with vdevgone(9).
Pseudo-drivers exposing a userland interface generally start & stop I/O
in *_open() and *_close() respectively. So it isn't safe to detach such
device while it is still open, because I/O might still be in flight.
A more generic fix would be to detach children devices before the parents.
Fix a race reported by Kevin Chadwick on bugs@.
Discussed with Peter Stuge, tested by and ok zhuk@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/uvideo.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index 7dbd0176847..d33e3079acd 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvideo.c,v 1.205 2019/10/14 09:20:48 mpi Exp $ */ +/* $OpenBSD: uvideo.c,v 1.206 2020/01/16 09:59:26 mpi Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -644,11 +644,11 @@ uvideo_detach(struct device *self, int flags) /* Wait for outstanding requests to complete */ usbd_delay_ms(sc->sc_udev, UVIDEO_NFRAMES_MAX); - uvideo_vs_free_frame(sc); - if (sc->sc_videodev != NULL) rv = config_detach(sc->sc_videodev, flags); + uvideo_vs_free_frame(sc); + return (rv); } |