diff options
| author | drochner <drochner@NetBSD.org> | 2009-01-20 20:18:28 +0000 |
|---|---|---|
| committer | drochner <drochner@NetBSD.org> | 2009-01-20 20:18:28 +0000 |
| commit | 26a88cd4d50b70a884ef2b54a3c4e08e39d7beef (patch) | |
| tree | e15cd28a3358f551ae22c16bce474260d6a36c67 /sys/dev/video.c | |
| parent | 95dfcca096b1686856515778964c11f9505ff1e9 (diff) | |
-avoid eternal block if device is not streaming
-apply locking to avoid race in poll()
-fix an obviously wrong flag check
Diffstat (limited to 'sys/dev/video.c')
| -rw-r--r-- | sys/dev/video.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/video.c b/sys/dev/video.c index f8edddd50c9..0e942df577a 100644 --- a/sys/dev/video.c +++ b/sys/dev/video.c @@ -1,4 +1,4 @@ -/* $NetBSD: video.c,v 1.18 2008/12/23 03:22:29 jmorse Exp $ */ +/* $NetBSD: video.c,v 1.19 2009/01/20 20:18:28 drochner Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney <pat@polycrystal.org> @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.18 2008/12/23 03:22:29 jmorse Exp $"); +__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.19 2009/01/20 20:18:28 drochner Exp $"); #include "video.h" #if NVIDEO > 0 @@ -970,6 +970,10 @@ video_dequeue_buf(struct video_softc *sc, struct v4l2_buffer *buf) } else { /* Block until we have sample */ while ((vb = video_stream_dequeue(vs)) == NULL) { + if (!vs->vs_streaming) { + mutex_exit(&vs->vs_lock); + return EINVAL; + } err = cv_wait_sig(&vs->vs_sample_cv, &vs->vs_lock); if (err != 0) { @@ -1564,10 +1568,12 @@ videopoll(dev_t dev, int events, struct lwp *l) return POLLERR; } + mutex_enter(&vs->vs_lock); if (!SIMPLEQ_EMPTY(&sc->sc_stream_in.vs_egress)) revents |= events & (POLLIN | POLLRDNORM); else selrecord(l, &vs->vs_sel); + mutex_exit(&vs->vs_lock); return (revents); } @@ -1644,7 +1650,7 @@ video_stream_setup_bufs(struct video_stream *vs, /* Ensure that all allocated buffers are queued and not under * userspace control. */ for (i = 0; i < vs->vs_nbufs; ++i) { - if (!(vs->vs_buf[i]->vb_buf->flags | V4L2_BUF_FLAG_QUEUED)) { + if (!(vs->vs_buf[i]->vb_buf->flags & V4L2_BUF_FLAG_QUEUED)) { mutex_exit(&vs->vs_lock); return EBUSY; } |
