diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2026-07-22 08:18:23 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2026-07-22 15:10:58 +0000 |
| commit | 12b4a02bd88117b07f3e142af71b70bade4fd57e (patch) | |
| tree | 68cb23c4f63bd4e254ffd033c6e77d9703ba8b41 | |
| parent | 2120f3e5ec701d92848c259ece4dfbf1aa95f6cb (diff) | |
| -rw-r--r-- | sys/dev/usb/video/uvideo.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/dev/usb/video/uvideo.c b/sys/dev/usb/video/uvideo.c index bfcd6696a8e0..57d31d2b5286 100644 --- a/sys/dev/usb/video/uvideo.c +++ b/sys/dev/usb/video/uvideo.c @@ -960,21 +960,20 @@ uvideo_detach(device_t dev) sc->sc_dying = 1; - /* Stop any active streaming */ - if (sc->sc_streaming) { - mtx_lock(&sc->sc_mtx); - sc->sc_streaming = 0; - mtx_unlock(&sc->sc_mtx); - uvideo_vs_close(sc); - } - /* Destroy character device */ if (sc->sc_cdev != NULL) { destroy_dev(sc->sc_cdev); sc->sc_cdev = NULL; } - /* Unit number is implicitly freed when the cdev is destroyed */ + /* Stop streaming if still active (e.g. detached while idle). */ + mtx_lock(&sc->sc_mtx); + if (sc->sc_streaming) { + sc->sc_streaming = 0; + mtx_unlock(&sc->sc_mtx); + uvideo_vs_close(sc); + } else + mtx_unlock(&sc->sc_mtx); /* Free frame buffers */ uvideo_vs_free_frame(sc); @@ -2911,12 +2910,13 @@ uvideo_cdev_close(struct cdev *dev, int flags, int fmt, struct thread *td) mtx_unlock(&sc->sc_mtx); /* Last close: stop streaming if still active (safety net) */ + mtx_lock(&sc->sc_mtx); if (sc->sc_streaming) { - mtx_lock(&sc->sc_mtx); sc->sc_streaming = 0; mtx_unlock(&sc->sc_mtx); uvideo_vs_close(sc); - } + } else + mtx_unlock(&sc->sc_mtx); uvideo_vs_free_frame(sc); |
