media.c: fix array overrun in media_entity_subtype_to_string()
authorTodor Tomov <ttomov@mm-sol.com>
Tue, 4 Jan 2011 09:49:55 +0000 (11:49 +0200)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 4 Jan 2011 22:28:10 +0000 (23:28 +0100)
Fix overrun of static arrays node_types and subdev_types in
media_entity_subtype_to_string().

Signed-off-by: Todor Tomov <ttomov@mm-sol.com>
media.c

diff --git a/media.c b/media.c
index 813a38f..75ca24c 100644 (file)
--- a/media.c
+++ b/media.c
@@ -82,12 +82,12 @@ static const char *media_entity_subtype_to_string(unsigned type)
 
        switch (type & MEDIA_ENTITY_TYPE_MASK) {
        case MEDIA_ENTITY_TYPE_NODE:
 
        switch (type & MEDIA_ENTITY_TYPE_MASK) {
        case MEDIA_ENTITY_TYPE_NODE:
-               if (subtype > ARRAY_SIZE(node_types))
+               if (subtype >= ARRAY_SIZE(node_types))
                        subtype = 0;
                return node_types[subtype];
 
        case MEDIA_ENTITY_TYPE_SUBDEV:
                        subtype = 0;
                return node_types[subtype];
 
        case MEDIA_ENTITY_TYPE_SUBDEV:
-               if (subtype > ARRAY_SIZE(subdev_types))
+               if (subtype >= ARRAY_SIZE(subdev_types))
                        subtype = 0;
                return subdev_types[subtype];
        default:
                        subtype = 0;
                return subdev_types[subtype];
        default: