diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2021-02-17 17:09:13 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2021-02-17 17:09:13 +0000 |
commit | 9bb83551542fbbfe74ec286457620badbee16d4a (patch) | |
tree | 5092de5c797831c34afc5239208961c0dfbc64ac /sys | |
parent | f1a0858385acee16e8eacd25db4abdb764716db2 (diff) |
If the device driver open call fails, don't set sc_open since in that case
we don't get a file handle back which could be closed again, and therefore
we couldn't toggle sc_open back to zero.
Spotted and ok anton@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/video.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/dev/video.c b/sys/dev/video.c index 57d960a7fe2..368e69fa270 100644 --- a/sys/dev/video.c +++ b/sys/dev/video.c @@ -1,4 +1,4 @@ -/* $OpenBSD: video.c,v 1.52 2021/02/17 08:51:40 mglocker Exp $ */ +/* $OpenBSD: video.c,v 1.53 2021/02/17 17:09:12 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -139,17 +139,19 @@ videoopen(dev_t dev, int flags, int fmt, struct proc *p) if (sc->sc_open) { DPRINTF(1, "%s: device already open\n", __func__); return (0); - } else { - sc->sc_open = 1; - DPRINTF(1, "%s: set device to open\n", __func__); } sc->sc_vidmode = VIDMODE_NONE; sc->sc_frames_ready = 0; - if (sc->hw_if->open != NULL) + if (sc->hw_if->open != NULL) { error = sc->hw_if->open(sc->hw_hdl, flags, &sc->sc_fsize, sc->sc_fbuffer, video_intr, sc); + } + if (error == 0) { + sc->sc_open = 1; + DPRINTF(1, "%s: set device to open\n", __func__); + } return (error); } |