lists.zerezo.com
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PATCH: gspca-ctrl-fixes.patch
- Date: Sun, 24 Aug 2008 09:03:58 +0200
- From: Hans de Goede <j.w.r.degoede@xxxxxx>
- Subject: PATCH: gspca-ctrl-fixes.patch
Hi,
While working on the Pixart 73xx controls code I noticed your new disabled
controls code (nice) and I've taken a look at that. This patch contains 2 fixes:
-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.
The first fix is not tested (I dunno of a program which actually uses this),
but upon reading the code, and stepping through it in my mind, the old code
seems wrong, and the new code after this patch seems right.
Regards,
Hans
-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 <j.w.r.degoede@xxxxxx>
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);
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list