From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: Jean-Francois Moine <moinejf@free.fr>
Cc: Linux and Kernel Video <video4linux-list@redhat.com>
Subject: PATCH: gspca-ctrl-fixes.patch
Date: Sun, 24 Aug 2008 09:03:58 +0200 [thread overview]
Message-ID: <48B107DE.2060006@hhs.nl> (raw)
[-- 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
reply other threads:[~2008-08-24 6:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48B107DE.2060006@hhs.nl \
--to=j.w.r.degoede@hhs.nl \
--cc=moinejf@free.fr \
--cc=video4linux-list@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox