Skip to contentSkip to conversation

media: mc: Fix graph walk in media_pipeline_start

PATCH New Tomi Valkeinen 1 participant 1 message Mar 18, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: mc: Fix graph walk in media_pipeline_start

The graph walk tries to follow all links, even if they are not between pads. This causes a crash with, e.g. a MEDIA_LNK_FL_ANCILLARY_LINK link.

Fix this by allowing the walk to proceed only for MEDIA_LNK_FL_DATA_LINK links.

Fixes ae219872834a ("media: mc: entity: Rewrite media_pipeline_start()")

---
Changes in v2:
- Move the check a bit earlier, so that we don't do a debug print for
ancillary links using data link fields.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/media/mc/mc-entity.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/mc/mc-entity.c +6 -0
index 543a392f8635..3fd3dab81ea1 100644
@@ -615,6 +615,12 @@ static int media_pipeline_explore_next_link(struct media_pipeline *pipe,
 	link = list_entry(entry->links, typeof(*link), list);
 	media_pipeline_walk_pop(walk);
 
+	if ((link->flags & MEDIA_LNK_FL_LINK_TYPE) != MEDIA_LNK_FL_DATA_LINK) {
+		dev_dbg(walk->mdev->dev,
+			"media pipeline: skipping link (not data-link)\n");
+		return 0;
+	}
+
 	dev_dbg(walk->mdev->dev,
 		"media pipeline: exploring link '%s':%u -> '%s':%u\n",
 		link->source->entity->name, link->source->index,

---
base-commit: e8f897f4afef0031fe618a8e94127a0934896aba
change-id: 20240315-mc-graph-fix-8a2a245d7346

Best regards,

Signature · 1 line
Tomi Valkeinen <[email protected]>