Hi,

In v4l2 VIDIOC_REQBUFS ioctl, a count value of zero frees all buffers.
We do not support it, and worse, it triggers a kernel panic.

Return EINVAL in this case so app can detect we do not allow it. While 
there change the easily triggerable panic by a printf and return EINVAL.

With that gstreamer1 correcly fallback and works.

ok ? comments ?

Index: uvideo.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/uvideo.c,v
retrieving revision 1.176
diff -u -p -r1.176 uvideo.c
--- uvideo.c    18 Oct 2014 08:01:34 -0000      1.176
+++ uvideo.c    18 Oct 2014 09:01:04 -0000
@@ -3092,8 +3092,14 @@ uvideo_reqbufs(void *v, struct v4l2_requ
 
        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 raqbufs(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)

Reply via email to