mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Jichen <wangjichen@kaihong.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: syzbot+8769efb8c3d52870334c@syzkaller.appspotmail.com
Subject: [PATCH] media: em28xx: check media_device_init() before register
Date: Fri, 27 Nov 2026 03:50:23 +0000	[thread overview]
Message-ID: <20261127035024.3598938-1-wangjichen@kaihong.com> (raw)

em28xx_init_dev() ignored -ENOMEM from em28xx_media_device_init() while
em28xx_usb_probe() still called media_device_register(NULL) under
CONFIG_MEDIA_CONTROLLER.

Reported-by: syzbot+8769efb8c3d52870334c@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=8769efb8c3d52870334c
Signed-off-by: Wang Jichen <wangjichen@kaihong.com>
---
 drivers/media/usb/em28xx/em28xx-cards.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 8440eafad..8618f4077 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3944,7 +3944,9 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
 	else
 		dev_info(&dev->intf->dev, "chip ID is %s\n", chip_name);
 
-	em28xx_media_device_init(dev, udev);
+	retval = em28xx_media_device_init(dev, udev);
+	if (retval)
+		return retval;
 
 	if (dev->is_audio_only) {
 		retval = em28xx_audio_setup(dev);
@@ -4438,11 +4440,13 @@ static int em28xx_usb_probe(struct usb_interface *intf,
 	 * topology will likely change after the load of the em28xx subdrivers.
 	 */
 #ifdef CONFIG_MEDIA_CONTROLLER
-	/*
-	 * No need to check the return value, the device will still be
-	 * usable without media controller API.
-	 */
-	retval = media_device_register(dev->media_dev);
+	if (dev->media_dev) {
+		/*
+		 * media_device_register() may fail; the device remains usable
+		 * without the media controller API in that case.
+		 */
+		media_device_register(dev->media_dev);
+	}
 #endif
 
 	return 0;
-- 
2.34.1


                 reply	other threads:[~2026-11-27  3:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261127035024.3598938-1-wangjichen@kaihong.com \
    --to=wangjichen@kaihong.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=syzbot+8769efb8c3d52870334c@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

all inboxes | Powered by JetHome®