media: entity: Skip non-data links in graph iteration
authorDaniel Scally <djrscally@gmail.com>
Wed, 2 Mar 2022 22:03:00 +0000 (22:03 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sun, 24 Apr 2022 06:57:21 +0000 (07:57 +0100)
When iterating over the media graph, don't follow links that are not
data links.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/mc/mc-entity.c

index 20f5a76bd78b6c40cb817cfd2700d4e973571e50..379898ca704c73e1982ff19b122add6e43d44894 100644 (file)
@@ -295,6 +295,12 @@ static void media_graph_walk_iter(struct media_graph *graph)
 
        link = list_entry(link_top(graph), typeof(*link), list);
 
+       /* If the link is not a data link, don't follow it */
+       if ((link->flags & MEDIA_LNK_FL_LINK_TYPE) != MEDIA_LNK_FL_DATA_LINK) {
+               link_top(graph) = link_top(graph)->next;
+               return;
+       }
+
        /* The link is not enabled so we do not follow. */
        if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {
                link_top(graph) = link_top(graph)->next;