media.c: fix NULL pointer dereference in media_enum_links()
authorTodor Tomov <ttomov@mm-sol.com>
Tue, 4 Jan 2011 09:49:56 +0000 (11:49 +0200)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 4 Jan 2011 22:28:15 +0000 (23:28 +0100)
Do not dereference source and sink in media_enum_links() if one
of them is NULL.

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

diff --git a/media.c b/media.c
index 75ca24c..d5d98de 100644 (file)
--- a/media.c
+++ b/media.c
@@ -424,11 +424,11 @@ static int media_enum_links(struct media_device *media)
                                        id, i, link->source.entity, link->source.index,
                                        link->sink.entity, link->sink.index);
                                ret = -EINVAL;
+                       } else {
+                               entity->links[i].source = &source->pads[link->source.index];
+                               entity->links[i].sink = &sink->pads[link->sink.index];
+                               entity->links[i].flags = links.links[i].flags;
                        }
-
-                       entity->links[i].source = &source->pads[link->source.index];
-                       entity->links[i].sink = &sink->pads[link->sink.index];
-                       entity->links[i].flags = links.links[i].flags;
                }
 
                free(links.pads);