diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2008-07-23 22:10:22 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2008-07-23 22:10:22 +0000 |
commit | 0f9a4cc37a3fbee118e2e6da444c286a74e164df (patch) | |
tree | a917aafc9500328d4d287cdf66afd69bc224e4a3 /sys/dev/video.c | |
parent | 44cec180ef0f1cf49f60f62b98c7d85f26735faf (diff) |
If /dev/video* is already used by an application, return EBUSY to other
applications. Fixes a kernel panic.
Reported by ian@
Diffstat (limited to 'sys/dev/video.c')
-rw-r--r-- | sys/dev/video.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/video.c b/sys/dev/video.c index 57d69a2847c..cfa33d97126 100644 --- a/sys/dev/video.c +++ b/sys/dev/video.c @@ -1,4 +1,4 @@ -/* $OpenBSD: video.c,v 1.17 2008/07/19 06:39:00 mglocker Exp $ */ +/* $OpenBSD: video.c,v 1.18 2008/07/23 22:10:21 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> * Copyright (c) 2008 Marcus Glocker <mglocker@openbsd.org> @@ -97,6 +97,10 @@ videoopen(dev_t dev, int flags, int fmt, struct proc *p) sc->hw_if == NULL) return (ENXIO); + if (sc->sc_open & VIDEO_OPEN) + return (EBUSY); + sc->sc_open |= VIDEO_OPEN; + sc->sc_start_read = 0; if (sc->hw_if->open != NULL) @@ -110,13 +114,16 @@ int videoclose(dev_t dev, int flags, int fmt, struct proc *p) { struct video_softc *sc; + int r = 0; sc = video_cd.cd_devs[VIDEOUNIT(dev)]; if (sc->hw_if->close != NULL) - return (sc->hw_if->close(sc->hw_hdl)); - else - return (0); + r = sc->hw_if->close(sc->hw_hdl); + + sc->sc_open &= ~VIDEO_OPEN; + + return (r); } int |