V4L/DVB (11260): v4l2-ioctl: Check format for S_PARM and G_PARM
authorTrent Piepho <xyzzy@speakeasy.org>
Sun, 29 Mar 2009 01:25:35 +0000 (22:25 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:44 +0000 (12:43 -0300)
Return EINVAL if VIDIOC_S/G_PARM is called for a buffer type that the
driver doesn't define a ->vidioc_try_fmt_XXX() method for.  Several other
ioctls, like QUERYBUF, QBUF, and DQBUF, etc.  do this too.  It saves each
driver from having to check if the buffer type is one that it supports.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/v4l2-ioctl.c

index 54ba6b0b951f49fa5d79edae7acbb207fc16a434..f41c6f506f4209e11ba7885f1833a43ad7656f62 100644 (file)
@@ -1551,6 +1551,9 @@ static long __video_do_ioctl(struct file *file,
                struct v4l2_streamparm *p = arg;
 
                if (ops->vidioc_g_parm) {
+                       ret = check_fmt(ops, p->type);
+                       if (ret)
+                               break;
                        ret = ops->vidioc_g_parm(file, fh, p);
                } else {
                        if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -1570,6 +1573,10 @@ static long __video_do_ioctl(struct file *file,
 
                if (!ops->vidioc_s_parm)
                        break;
+               ret = check_fmt(ops, p->type);
+               if (ret)
+                       break;
+
                dbgarg(cmd, "type=%d\n", p->type);
                ret = ops->vidioc_s_parm(file, fh, p);
                break;