Linux Media Controller development
 help / color / mirror / Atom feed
From: gshahrouzi@gmail.com
To: laurent.pinchart@ideasonboard.com
Cc: hdegoede@redhat.com,mchehab@kernel.org,linux-media@vger.kernel.org,linux-kernel@vger.kernel.org,syzbot+701fc9cc0cb44e2b0fe9@syzkaller.appspotmail.com,skhan@linuxfoundation.org,kernelmentees@lists.linuxfoundation.org
Subject: [PATCH] media: Fix invalid link creation when source entity has 0 pads
Date: Tue, 25 Mar 2025 00:55:03 -0700 (PDT)	[thread overview]
Message-ID: <67e26157.0c0a0220.36adcd.506e@mx.google.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1550 bytes --]

>From 307209d175be0145e36b9cf95944e2e62afeab11 Mon Sep 17 00:00:00 2001
From: Gabriel Shahrouzi <gshahrouzi@gmail.com>
Date: Mon, 24 Mar 2025 19:45:55 -0400
Subject: [PATCH] media: Fix invalid link creation when source entity has 0
 pads

This patch addresses the warning triggered in the media_create_pad_link()
function, specifically related to the check WARN_ON(source_pad >=
source->num_pads). The fix proposed adds an additional check to ensure that
source->num_pads is non-zero before proceeding with the
media_create_pad_link() function.

Reported-by: syzbot+701fc9cc0cb44e2b0fe9@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=701fc9cc0cb44e2b0fe9
Tested-by: syzbot+701fc9cc0cb44e2b0fe9@syzkaller.appspotmail.com
Fixes: a3fbc2e6bb05 ("media: mc-entity.c: use WARN_ON, validate link pads")
Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
---
 drivers/media/usb/uvc/uvc_entity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c
index cc68dd24eb42..5397ce76c218 100644
--- a/drivers/media/usb/uvc/uvc_entity.c
+++ b/drivers/media/usb/uvc/uvc_entity.c
@@ -43,7 +43,7 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain,
 		source = (UVC_ENTITY_TYPE(remote) == UVC_TT_STREAMING)
 		       ? (remote->vdev ? &remote->vdev->entity : NULL)
 		       : &remote->subdev.entity;
-		if (source == NULL)
+		if (source == NULL || source->num_pads == 0)
 			continue;
 
 		remote_pad = remote->num_pads - 1;
-- 
2.43.0


             reply	other threads:[~2025-03-25  7:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25  7:55 gshahrouzi [this message]
2025-03-25  8:56 ` [PATCH] media: Fix invalid link creation when source entity has 0 pads Ricardo Ribalda
2025-03-25 22:05   ` Gabriel
2025-03-26  0:13     ` Laurent Pinchart
2025-03-29 17:50       ` Gabriel
2025-04-02  0:29         ` Laurent Pinchart
2025-04-08  5:35           ` Gabriel Shahrouzi
2025-04-09 20:54             ` Laurent Pinchart
2025-04-11  5:05               ` Gabriel Shahrouzi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67e26157.0c0a0220.36adcd.506e@mx.google.com \
    --to=gshahrouzi@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=kernelmentees@lists.linuxfoundation.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=syzbot+701fc9cc0cb44e2b0fe9@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox