[media] v4l2-subdev.c: add 'which' checks for enum ops
authorHans Verkuil <[email protected]>
Wed, 4 Mar 2015 09:47:56 +0000 (01:47 -0800)
committerMauro Carvalho Chehab <[email protected]>
Mon, 23 Mar 2015 18:45:07 +0000 (11:45 -0700)
Return an error if an invalid 'which' valid is passed in.

Signed-off-by: Hans Verkuil <[email protected]>
Acked-by: Lad, Prabhakar <[email protected]>
Tested-by: Lad, Prabhakar <[email protected]>
Acked-by: Laurent Pinchart <[email protected]>
Acked-by: Sylwester Nawrocki <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
drivers/media/v4l2-core/v4l2-subdev.c

index 3c8b198a0622beef1196cd4ed09f622642704ca1..8bafb942552b5f25fda7837b8553118984d53dc0 100644 (file)
@@ -321,6 +321,10 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
        case VIDIOC_SUBDEV_ENUM_MBUS_CODE: {
                struct v4l2_subdev_mbus_code_enum *code = arg;
 
+               if (code->which != V4L2_SUBDEV_FORMAT_TRY &&
+                   code->which != V4L2_SUBDEV_FORMAT_ACTIVE)
+                       return -EINVAL;
+
                if (code->pad >= sd->entity.num_pads)
                        return -EINVAL;
 
@@ -331,6 +335,10 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
        case VIDIOC_SUBDEV_ENUM_FRAME_SIZE: {
                struct v4l2_subdev_frame_size_enum *fse = arg;
 
+               if (fse->which != V4L2_SUBDEV_FORMAT_TRY &&
+                   fse->which != V4L2_SUBDEV_FORMAT_ACTIVE)
+                       return -EINVAL;
+
                if (fse->pad >= sd->entity.num_pads)
                        return -EINVAL;
 
@@ -359,6 +367,10 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
        case VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL: {
                struct v4l2_subdev_frame_interval_enum *fie = arg;
 
+               if (fie->which != V4L2_SUBDEV_FORMAT_TRY &&
+                   fie->which != V4L2_SUBDEV_FORMAT_ACTIVE)
+                       return -EINVAL;
+
                if (fie->pad >= sd->entity.num_pads)
                        return -EINVAL;