* [PATCH] media: em28xx: check media_device_init() before register @ 2026-11-27 3:50 Wang Jichen 2026-12-01 13:30 ` Hans Verkuil 2026-12-02 3:00 ` [PATCH v2] " Wang Jichen 0 siblings, 2 replies; 4+ messages in thread From: Wang Jichen @ 2026-11-27 3:50 UTC (permalink / raw) To: Mauro Carvalho Chehab, linux-media, linux-kernel Cc: syzbot+8769efb8c3d52870334c 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] media: em28xx: check media_device_init() before register 2026-11-27 3:50 [PATCH] media: em28xx: check media_device_init() before register Wang Jichen @ 2026-12-01 13:30 ` Hans Verkuil 2026-12-02 2:11 ` 王继晨 2026-12-02 3:00 ` [PATCH v2] " Wang Jichen 1 sibling, 1 reply; 4+ messages in thread From: Hans Verkuil @ 2026-12-01 13:30 UTC (permalink / raw) To: Wang Jichen, Mauro Carvalho Chehab, linux-media, linux-kernel Cc: syzbot+8769efb8c3d52870334c On 27/11/2026 04:50, Wang Jichen wrote: > 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; I get this compile warning: In file included from ./include/media/media-request.h:20, from ./include/media/videobuf2-core.h:20, from ./include/media/videobuf2-v4l2.h:16, from drivers/media/usb/em28xx/em28xx.h:28, from drivers/media/usb/em28xx/em28xx-cards.c:12: drivers/media/usb/em28xx/em28xx-cards.c: In function ‘em28xx_usb_probe’: ./include/media/media-device.h:291:37: warning: ignoring return value of ‘__media_device_register’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 291 | #define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/usb/em28xx/em28xx-cards.c:4459:17: note: in expansion of macro ‘media_device_register’ 4459 | media_device_register(dev->media_dev); | ^~~~~~~~~~~~~~~~~~~~~ ./include/media/media-device.h:291:37: warning: ignoring return value of ‘__media_device_register’ declared with attribute ‘warn_unused_result’ [-Wunused-result] Regards, Hans ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: em28xx: check media_device_init() before register 2026-12-01 13:30 ` Hans Verkuil @ 2026-12-02 2:11 ` 王继晨 0 siblings, 0 replies; 4+ messages in thread From: 王继晨 @ 2026-12-02 2:11 UTC (permalink / raw) To: Hans Verkuil Cc: Mauro Carvalho Chehab, linux-media, linux-kernel, syzbot+8769efb8c3d52870334c > From: "Hans Verkuil"<hverkuil+cisco@kernel.org> > Date: Tue, Dec 1, 2026, 21:30 > Subject: Re: [PATCH] media: em28xx: check media_device_init() before register > To: "Wang Jichen"<wangjichen@kaihong.com>, "Mauro Carvalho Chehab"<mchehab@kernel.org>, <linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org> > Cc: <syzbot+8769efb8c3d52870334c@syzkaller.appspotmail.com> > On 27/11/2026 04:50, Wang Jichen wrote: > > 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; > > I get this compile warning: > > In file included from ./include/media/media-request.h:20, > from ./include/media/videobuf2-core.h:20, > from ./include/media/videobuf2-v4l2.h:16, > from drivers/media/usb/em28xx/em28xx.h:28, > from drivers/media/usb/em28xx/em28xx-cards.c:12: > drivers/media/usb/em28xx/em28xx-cards.c: In function ‘em28xx_usb_probe’: > ./include/media/media-device.h:291:37: warning: ignoring return value of ‘__media_device_register’ declared with attribute ‘warn_unused_result’ [-Wunused-result] > 291 | #define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/media/usb/em28xx/em28xx-cards.c:4459:17: note: in expansion of macro ‘media_device_register’ > 4459 | media_device_register(dev->media_dev); > | ^~~~~~~~~~~~~~~~~~~~~ > ./include/media/media-device.h:291:37: warning: ignoring return value of ‘__media_device_register’ declared with attribute ‘warn_unused_result’ [-Wunused-result] > > Regards, > > Hans > Hi Thanks for the report,This is a known issue — syzbot had already flagged the unchecked media_device_register() return value before the Media CI robot caught it on-list. https://lore.kernel.org/all/8b878c802e81b6b8dc57299e05cbda9f3dc94e50.c31abfb7.34f2.47d2.9300.0c94396057a9@feishu.cn/ I'm preparing a v2 that properly checks the return value and handles the error path, and I'll send it shortly. The v2 will supersede the earlier version. Thanks, Jichen ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] media: em28xx: check media_device_init() before register 2026-11-27 3:50 [PATCH] media: em28xx: check media_device_init() before register Wang Jichen 2026-12-01 13:30 ` Hans Verkuil @ 2026-12-02 3:00 ` Wang Jichen 1 sibling, 0 replies; 4+ messages in thread From: Wang Jichen @ 2026-12-02 3:00 UTC (permalink / raw) To: Hans Verkuil, Mauro Carvalho Chehab, linux-media, linux-kernel Cc: syzbot+8769efb8c3d52870334c 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..3886c720a 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. + */ + retval = media_device_register(dev->media_dev); + } #endif return 0; -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 3:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 3:50 [PATCH] media: em28xx: check media_device_init() before register Wang Jichen 2026-12-01 13:30 ` Hans Verkuil 2026-12-02 2:11 ` 王继晨 2026-12-02 3:00 ` [PATCH v2] " Wang Jichen
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.