Skip to contentSkip to conversation

media: em28xx: check media_device_init() before register

PATCH New Wang Jichen 1 participant 1 message Nov 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: em28xx: check media_device_init() before register

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

---
 drivers/media/usb/em28xx/em28xx-cards.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +10 -6
index 8440eafad..8618f4077 100644
@@ -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;
Signature · 1 line
2.34.1