[media] v4l: do not allow modulator ioctls for non-radio devices
authorHans Verkuil <hverkuil@xs4all.nl>
Fri, 20 Dec 2013 05:32:21 +0000 (02:32 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 5 Mar 2014 17:16:00 +0000 (14:16 -0300)
Modulator ioctls could be enabled mistakenly for non-radio devices.
Currently those ioctls are only valid for radio. Fix it.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/v4l2-dev.c

index 98099e827614d91969ad090d08513bf6796a3aa1..95112f686ef060045c8c52b2ced0cee01c303a6c 100644 (file)
@@ -553,6 +553,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
        const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;
        bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER;
        bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI;
+       bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO;
        bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR;
        bool is_rx = vdev->vfl_dir != VFL_DIR_TX;
        bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
@@ -726,8 +727,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
                SET_VALID_IOCTL(ops, VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings);
                SET_VALID_IOCTL(ops, VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap);
        }
-       if (is_tx) {
-               /* transmitter only ioctls */
+       if (is_tx && (is_radio || is_sdr)) {
+               /* radio transmitter only ioctls */
                SET_VALID_IOCTL(ops, VIDIOC_G_MODULATOR, vidioc_g_modulator);
                SET_VALID_IOCTL(ops, VIDIOC_S_MODULATOR, vidioc_s_modulator);
        }