Forwarded: [PATCH] media: mc: Remove spurious WARN_ON in __media_pipeline_start

syzbot posted 1 patch 1 month, 1 week ago
drivers/media/mc/mc-entity.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
Forwarded: [PATCH] media: mc: Remove spurious WARN_ON in __media_pipeline_start
Posted by syzbot 1 month, 1 week ago
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: [PATCH] media: mc: Remove spurious WARN_ON in __media_pipeline_start
Author: niharikakhare2101@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3eb40771c00a8488fa6ed2cc1fe203477908bf38

Reported-by: syzbot+68e901d044baaea1f60c@syzkaller.appspotmail.com
Signed-off-by: Niharika Khare <niharikakhare2101@gmail.com>
---
 drivers/media/mc/mc-entity.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 3fa0bc687851..8e4e941381d9 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -779,11 +779,17 @@ __must_check int __media_pipeline_start(struct media_pad *origin,
 	lockdep_assert_held(&mdev->graph_mutex);
 
 	/*
-	 * If the pad is already part of a pipeline, that pipeline must be the
-	 * same as the pipe given to media_pipeline_start().
+	 * If the pad is attached to a different pipeline than the one passed on
+	 * to media_pipeline_start(), the pad must wait for the ongoing session
+	 * on this previous pipeline to complete before it starts a new session. 
+	 * The request for starting the pipeline, although valid, cannot be
+	 * served until the ongoing request finishes.
 	 */
-	if (WARN_ON(origin->pipe && origin->pipe != pipe))
-		return -EINVAL;
+	if (origin->pipe && origin->pipe != pipe) {
+		dev_dbg(mdev->dev, "Failed to start pipeline: pad '%s':%u busy\n",
+			origin->entity->name, origin->index);
+		return -EBUSY;
+	}
 
 	/*
 	 * If the pipeline has already been started, it is guaranteed to be
-- 
2.53.0