V4L/DVB (8815): gspca: Fix problems with disabled controls.
authorHans de Goede <j.w.r.degoede@hhs.nl>
Wed, 3 Sep 2008 20:12:14 +0000 (17:12 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 3 Sep 2008 21:37:28 +0000 (18:37 -0300)
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/gspca.c

index 33161e1e0bcc925784eefa4a74c8be9c685ecf1f..e7e73ec7134c8e1445eaad4d636bf42e7f9c4d6d 100644 (file)
@@ -869,7 +869,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
                id &= V4L2_CTRL_ID_MASK;
                id++;
                for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) {
-                       if (id < gspca_dev->sd_desc->ctrls[i].qctrl.id)
+                       if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id)
                                continue;
                        if (ix < 0) {
                                ix = i;
@@ -908,6 +908,8 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
             i++, ctrls++) {
                if (ctrl->id != ctrls->qctrl.id)
                        continue;
+               if (gspca_dev->ctrl_dis & (1 << i))
+                       return -EINVAL;
                if (ctrl->value < ctrls->qctrl.minimum
                    || ctrl->value > ctrls->qctrl.maximum)
                        return -ERANGE;
@@ -934,6 +936,8 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
             i++, ctrls++) {
                if (ctrl->id != ctrls->qctrl.id)
                        continue;
+               if (gspca_dev->ctrl_dis & (1 << i))
+                       return -EINVAL;
                if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                        return -ERESTARTSYS;
                ret = ctrls->get(gspca_dev, &ctrl->value);