* PATCH: gspca-ctrl-fixes.patch
@ 2008-08-24 7:03 Hans de Goede
0 siblings, 0 replies; only message in thread
From: Hans de Goede @ 2008-08-24 7:03 UTC (permalink / raw)
To: Jean-Francois Moine; +Cc: Linux and Kernel Video
[-- Attachment #1: Type: text/plain, Size: 694 bytes --]
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
[-- Attachment #2: gspca-ctrl-fixes.patch --]
[-- Type: text/plain, Size: 1363 bytes --]
-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@hhs.nl>
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);
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-24 6:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-24 7:03 PATCH: gspca-ctrl-fixes.patch Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox