summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorJonathan Armani <armani@cvs.openbsd.org>2015-01-06 17:27:59 +0000
committerJonathan Armani <armani@cvs.openbsd.org>2015-01-06 17:27:59 +0000
commit3c81041c4f1aebbb1e7dec205e55220861d62baa (patch)
tree71cffe843bbeb4b8b7b992e862c02751e2891cec /sys/dev/usb
parent08198fa6b7882281a4f3e7218b6faaabdf3cbe5b (diff)
We do not support freeing memory using reqbufs with a zero size so
return EINVAL in this case. Also change an easily triggerable panic by a printf and return EINVAL. Reminded by brad@, one typo spotted by sthen@ and ok mpi@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/uvideo.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 4f3d33eeec8..4d90f5b6e41 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.178 2014/11/18 23:55:01 krw Exp $ */
+/* $OpenBSD: uvideo.c,v 1.179 2015/01/06 17:27:58 armani Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -3091,8 +3091,14 @@ uvideo_reqbufs(void *v, struct v4l2_requestbuffers *rb)
DPRINTF(1, "%s: %s: count=%d\n", DEVNAME(sc), __func__, rb->count);
- if (sc->sc_mmap_count > 0 || sc->sc_mmap_buffer != NULL)
- panic("%s: mmap buffers already allocated", __func__);
+ /* We do not support freeing buffers via reqbufs(0) */
+ if (rb->count == 0)
+ return (EINVAL);
+
+ if (sc->sc_mmap_count > 0 || sc->sc_mmap_buffer != NULL) {
+ printf("%s: mmap buffers already allocated\n", __func__);
+ return (EINVAL);
+ }
/* limit the buffers */
if (rb->count > UVIDEO_MAX_BUFFERS)