* [PATCH] media: mc: Reject disconnected pads on an active pipeline
@ 2026-11-24 16:37 Anthony McGivern
2026-12-03 8:05 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Anthony McGivern @ 2026-11-24 16:37 UTC (permalink / raw)
To: linux-media
Cc: Anthony McGivern, Vincenzo Frascino, Nayden Kanchev,
Konstantin Babin, Linus Walleij, Mauro Carvalho Chehab,
Hans Verkuil, laurent.pinchart, Sakari Ailus, Anthony McGivern
From: Anthony McGivern <Anthony.McGivern@arm.com>
When starting an already active media pipeline, graph validation is skipped
and its start count is incremented. This allows a disconnected origin pad
to return success even though it does not belong to a pipeline.
Reject a disconnected origin pad with -EINVAL before incrementing the
start count.
Signed-off-by: Anthony McGivern <Anthony.McGivern@arm.com>
---
drivers/media/mc/mc-entity.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 7938f785e2e3c76372a585426faa0482d78083ef..4508afacdd68e2a9ab81261561997317ab525662 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -791,10 +791,13 @@ __must_check int __media_pipeline_start(struct media_pad *origin,
return -EINVAL;
/*
- * If the pipeline has already been started, it is guaranteed to be
- * valid, so just increase the start count.
+ * If the pipeline has already been started, ensure the pad is a part of the pipeline.
+ * If so, it is guaranteed to be valid, so just increase the start count.
*/
if (pipe->start_count) {
+ if (!origin->pipe)
+ return -EINVAL;
+
pipe->start_count++;
return 0;
}
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261124-mali-c720-media-controller-fix-3efb64d9cd6d
Best regards,
--
Anthony McGivern <Anthony.McGivern@arm.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: mc: Reject disconnected pads on an active pipeline
2026-11-24 16:37 [PATCH] media: mc: Reject disconnected pads on an active pipeline Anthony McGivern
@ 2026-12-03 8:05 ` Linus Walleij
2026-12-03 12:23 ` Anthony McGivern
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2026-12-03 8:05 UTC (permalink / raw)
To: Anthony McGivern
Cc: linux-media, Vincenzo Frascino, Nayden Kanchev, Konstantin Babin,
Mauro Carvalho Chehab, Hans Verkuil, laurent.pinchart,
Sakari Ailus
Hi Anthony,
thanks for your patch!
On Tue, Nov 24, 2026 at 5:38 PM Anthony McGivern
<anthony.mcgivern@arm.com> wrote:
> From: Anthony McGivern <Anthony.McGivern@arm.com>
>
> When starting an already active media pipeline, graph validation is skipped
> and its start count is incremented. This allows a disconnected origin pad
> to return success even though it does not belong to a pipeline.
>
> Reject a disconnected origin pad with -EINVAL before incrementing the
> start count.
>
> Signed-off-by: Anthony McGivern <Anthony.McGivern@arm.com>
Maybe also mention that this will surely give a WARN_ON() splat
from __media_pipeline_stop() unless this patch is applied?
I suppose this is how you found it?
(...)
> /*
> - * If the pipeline has already been started, it is guaranteed to be
> - * valid, so just increase the start count.
> + * If the pipeline has already been started, ensure the pad is a part of the pipeline.
> + * If so, it is guaranteed to be valid, so just increase the start count.
> */
> if (pipe->start_count) {
> + if (!origin->pipe)
> + return -EINVAL;
Should this be -ENOLINK?
I see this is used under similar circumstances (disconnected
node/pad) in the media framework.
Some media maintainer maybe can confirm.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: mc: Reject disconnected pads on an active pipeline
2026-12-03 8:05 ` Linus Walleij
@ 2026-12-03 12:23 ` Anthony McGivern
0 siblings, 0 replies; 3+ messages in thread
From: Anthony McGivern @ 2026-12-03 12:23 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-media, Vincenzo Frascino, Nayden Kanchev, Konstantin Babin,
Mauro Carvalho Chehab, Hans Verkuil, laurent.pinchart,
Sakari Ailus
Hi Linus,
On 03/12/2026 08:05, Linus Walleij wrote:
> Hi Anthony,
>
> thanks for your patch!
>
> On Tue, Nov 24, 2026 at 5:38 PM Anthony McGivern
> <anthony.mcgivern@arm.com> wrote:
>
>> From: Anthony McGivern <Anthony.McGivern@arm.com>
>>
>> When starting an already active media pipeline, graph validation is skipped
>> and its start count is incremented. This allows a disconnected origin pad
>> to return success even though it does not belong to a pipeline.
>>
>> Reject a disconnected origin pad with -EINVAL before incrementing the
>> start count.
>>
>> Signed-off-by: Anthony McGivern <Anthony.McGivern@arm.com>
>
> Maybe also mention that this will surely give a WARN_ON() splat
> from __media_pipeline_stop() unless this patch is applied?
> I suppose this is how you found it?
Good point, yeah this indicated the issue to me initially as you have
described. I also noticed this as the start_count would also be mistakenly
incremented so any driver checks that depend on this could inadvertently
pass. In any case, I will update the description in V2 to state this
consequential WARN_ON().
Another thought would be how this differs to media_pipeline_alloc_start
where instead a new pipe would be allocated and run through its own
validation, thus failing for an unconnected pad if MUST_CONNECT is set.
Maybe for that reason it is preferred to use the alloc_start variant?
>
> (...)
>> /*
>> - * If the pipeline has already been started, it is guaranteed to be
>> - * valid, so just increase the start count.
>> + * If the pipeline has already been started, ensure the pad is a part of the pipeline.
>> + * If so, it is guaranteed to be valid, so just increase the start count.
>> */
>> if (pipe->start_count) {
>> + if (!origin->pipe)
>> + return -EINVAL;
>
> Should this be -ENOLINK?
>
> I see this is used under similar circumstances (disconnected
> node/pad) in the media framework.
>
> Some media maintainer maybe can confirm.
Yeah that does sound more reasonable, but I agree it would be good
to clarify this. If so I can make the change in V2.
>
> Yours,
> Linus Walleij
Thanks,
Anthony
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 12:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 16:37 [PATCH] media: mc: Reject disconnected pads on an active pipeline Anthony McGivern
2026-12-03 8:05 ` Linus Walleij
2026-12-03 12:23 ` Anthony McGivern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox