OSDN Git Service

[media] v4l2-dev: disable selection ioctls for non-video devices
authorHans Verkuil <hverkuil@xs4all.nl>
Fri, 13 Mar 2015 16:25:53 +0000 (13:25 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 2 Apr 2015 21:30:00 +0000 (18:30 -0300)
The selection/cropping ioctls are only valid for video nodes, not for vbi.

Found by v4l2-compliance when run on a VBI device node.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/v4l2-core/v4l2-dev.c

index e2b8b3e..71a1b93 100644 (file)
@@ -611,6 +611,14 @@ static void determine_valid_ioctls(struct video_device *vdev)
                SET_VALID_IOCTL(ops, VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd);
                SET_VALID_IOCTL(ops, VIDIOC_ENUM_FRAMESIZES, vidioc_enum_framesizes);
                SET_VALID_IOCTL(ops, VIDIOC_ENUM_FRAMEINTERVALS, vidioc_enum_frameintervals);
+               if (ops->vidioc_g_crop || ops->vidioc_g_selection)
+                       set_bit(_IOC_NR(VIDIOC_G_CROP), valid_ioctls);
+               if (ops->vidioc_s_crop || ops->vidioc_s_selection)
+                       set_bit(_IOC_NR(VIDIOC_S_CROP), valid_ioctls);
+               SET_VALID_IOCTL(ops, VIDIOC_G_SELECTION, vidioc_g_selection);
+               SET_VALID_IOCTL(ops, VIDIOC_S_SELECTION, vidioc_s_selection);
+               if (ops->vidioc_cropcap || ops->vidioc_g_selection)
+                       set_bit(_IOC_NR(VIDIOC_CROPCAP), valid_ioctls);
        } else if (is_vbi) {
                /* vbi specific ioctls */
                if ((is_rx && (ops->vidioc_g_fmt_vbi_cap ||
@@ -679,14 +687,6 @@ static void determine_valid_ioctls(struct video_device *vdev)
                        SET_VALID_IOCTL(ops, VIDIOC_G_AUDOUT, vidioc_g_audout);
                        SET_VALID_IOCTL(ops, VIDIOC_S_AUDOUT, vidioc_s_audout);
                }
-               if (ops->vidioc_g_crop || ops->vidioc_g_selection)
-                       set_bit(_IOC_NR(VIDIOC_G_CROP), valid_ioctls);
-               if (ops->vidioc_s_crop || ops->vidioc_s_selection)
-                       set_bit(_IOC_NR(VIDIOC_S_CROP), valid_ioctls);
-               SET_VALID_IOCTL(ops, VIDIOC_G_SELECTION, vidioc_g_selection);
-               SET_VALID_IOCTL(ops, VIDIOC_S_SELECTION, vidioc_s_selection);
-               if (ops->vidioc_cropcap || ops->vidioc_g_selection)
-                       set_bit(_IOC_NR(VIDIOC_CROPCAP), valid_ioctls);
                if (ops->vidioc_g_parm || (vdev->vfl_type == VFL_TYPE_GRABBER &&
                                        ops->vidioc_g_std))
                        set_bit(_IOC_NR(VIDIOC_G_PARM), valid_ioctls);