From: Kirill A. Korinsky Subject: Re: sys/uvideo: avoid using queue.h To: mvs@openbsd.org, marcus@nazgul.ch, tech@openbsd.org Date: Thu, 03 Apr 2025 16:39:18 +0200 On Fri, 21 Mar 2025 23:02:35 +0100, Kirill A. Korinsky wrote: > > On Fri, 21 Mar 2025 15:39:21 +0100, > Vitaliy Makkoveev wrote: > > > > Concurrent videoopen() could be called during possible context switch > > provided by sc->hw_if->close(). At least uvideo_vs_close() has such > > points. > > > > Thanks to notice it. Here an updated diff which keeps sc_open at original > place, and shouldn't introduce race condition. > What should we do with this remaining diff? Shall I drop it locally? Anyone would like to OK it? If commit now or after the release? Index: sys/dev/video.c =================================================================== RCS file: /home/cvs/src/sys/dev/video.c,v diff -u -p -r1.60 video.c --- sys/dev/video.c 21 Mar 2025 13:27:37 -0000 1.60 +++ sys/dev/video.c 21 Mar 2025 21:59:51 -0000 @@ -181,9 +181,15 @@ videoclose(dev_t dev, int flags, int fmt if (sc == NULL) return (ENXIO); + if (!sc->sc_open) { + error = ENXIO; + goto done; + } + error = video_stop(sc); sc->sc_open = 0; +done: device_unref(&sc->dev); return (error); }