-Fix reversed check in control enumeration -Report -EINVAL (as documented in the v4l spec) when an application tries to set/get a disabled control, this protects subdrivers against having their ctrl set/get methods called for disabled controls so they don't have to check for this themselves. Signed-off-by: Hans de Goede diff -r 9c27eaf44d47 linux/drivers/media/video/gspca/gspca.c --- a/linux/drivers/media/video/gspca/gspca.c Sat Aug 23 12:56:49 2008 +0200 +++ b/linux/drivers/media/video/gspca/gspca.c Sun Aug 24 08:58:44 2008 +0200 @@ -876,7 +876,7 @@ 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; @@ -915,6 +915,8 @@ 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; @@ -941,6 +943,8 @@ 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);