Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a46c5fbc6912c4e34cb7ded314249b639dc244a6
Commit:     a46c5fbc6912c4e34cb7ded314249b639dc244a6
Parent:     3d58ffe2aa107df6db57f875dba5368960b17cde
Author:     Hans Verkuil <[EMAIL PROTECTED]>
AuthorDate: Thu Jul 19 04:53:36 2007 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Fri Jul 20 17:35:53 2007 -0300

    V4L/DVB (5869): Add check for valid control ID to v4l2_ctrl_next.
    
    If v4l2_ctrl_next is called without the V4L2_CTRL_FLAG_NEXT_CTRL then it
    should check whether the passed control ID is valid and return 0 if it
    isn't. Otherwise a for-loop over the control IDs will never end.
    
    Signed-off-by: Hans Verkuil <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/video/v4l2-common.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/media/video/v4l2-common.c 
b/drivers/media/video/v4l2-common.c
index 13ee550..d2915d3 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -939,16 +939,25 @@ int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, 
struct v4l2_queryctrl *qc
    When no more controls are available 0 is returned. */
 u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id)
 {
-       u32 ctrl_class;
+       u32 ctrl_class = V4L2_CTRL_ID2CLASS(id);
        const u32 *pctrl;
 
-       /* if no query is desired, then just return the control ID */
-       if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0)
-               return id;
        if (ctrl_classes == NULL)
                return 0;
+
+       /* if no query is desired, then check if the ID is part of ctrl_classes 
*/
+       if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0) {
+               /* find class */
+               while (*ctrl_classes && V4L2_CTRL_ID2CLASS(**ctrl_classes) != 
ctrl_class)
+                       ctrl_classes++;
+               if (*ctrl_classes == NULL)
+                       return 0;
+               pctrl = *ctrl_classes;
+               /* find control ID */
+               while (*pctrl && *pctrl != id) pctrl++;
+               return *pctrl ? id : 0;
+       }
        id &= V4L2_CTRL_ID_MASK;
-       ctrl_class = V4L2_CTRL_ID2CLASS(id);
        id++;   /* select next control */
        /* find first class that matches (or is greater than) the class of
           the ID */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to