media: mc: Fix graph walk in media_pipeline_start

Message ID 20240315-mc-graph-fix-v1-1-91d59d752614@ideasonboard.com (mailing list archive)
State Superseded
Headers
Series media: mc: Fix graph walk in media_pipeline_start |

Commit Message

Tomi Valkeinen March 15, 2024, 3:12 p.m. UTC
  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.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Fixes: ae219872834a ("media: mc: entity: Rewrite media_pipeline_start()")
---
 drivers/media/mc/mc-entity.c | 6 ++++++
 1 file changed, 6 insertions(+)


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

Best regards,
  

Comments

Naushir Patuck March 18, 2024, 8:41 a.m. UTC | #1
Hi Tomi,

Thank you for this fix.

On Fri, 15 Mar 2024 at 15:13, Tomi Valkeinen
<tomi.valkeinen@ideasonboard.com> wrote:
>
> 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.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> Fixes: ae219872834a ("media: mc: entity: Rewrite media_pipeline_start()")

I was having problems with the Raspberry Pi Camera v3 module (IMX708 +
DW9817 VCM) that would crash in media_pipeline_start().  This patch
fixes the issue for me, so

Tested-by: Naushir Patuck <naush@raspberrypi.com>

> ---
>  drivers/media/mc/mc-entity.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> index 543a392f8635..fcafe5c59052 100644
> --- a/drivers/media/mc/mc-entity.c
> +++ b/drivers/media/mc/mc-entity.c
> @@ -627,6 +627,12 @@ static int media_pipeline_explore_next_link(struct media_pipeline *pipe,
>                 return 0;
>         }
>
> +       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;
> +       }
> +
>         /* Get the local pad and remote pad. */
>         if (link->source->entity == pad->entity) {
>                 local = link->source;
>
> ---
> base-commit: e8f897f4afef0031fe618a8e94127a0934896aba
> change-id: 20240315-mc-graph-fix-8a2a245d7346
>
> Best regards,
> --
> Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>
>
  

Patch

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 543a392f8635..fcafe5c59052 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -627,6 +627,12 @@  static int media_pipeline_explore_next_link(struct media_pipeline *pipe,
 		return 0;
 	}
 
+	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;
+	}
+
 	/* Get the local pad and remote pad. */
 	if (link->source->entity == pad->entity) {
 		local = link->source;