FAILED: patch "[PATCH] media: uvcvideo: Fix error path in control parsing failure" failed to apply to 4.4-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8c279e9394cade640ed86ec6c6645a0e7df5e0b6 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <[email protected]>
Date: Mon, 29 Jul 2019 23:14:55 -0300
Subject: [PATCH] media: uvcvideo: Fix error path in control parsing failure
When parsing the UVC control descriptors fails, the error path tries to cleanup a media device that hasn't been initialised, potentially resulting in a crash. Fix this by initialising the media device before the error handling path can be reached.
drivers/media/usb/uvc/uvc_driver.c +15 -13
@@ -2151,6 +2151,20 @@ static int uvc_probe(struct usb_interface *intf, sizeof(dev->name) - len); } +/* Initialize the media device. */ +#ifdef CONFIG_MEDIA_CONTROLLER + dev->mdev.dev = &intf->dev; +strscpy (dev->mdev.model, dev->name,sizeof (dev->mdev.model)); +if (udev->serial) +strscpy (dev->mdev.serial, udev->serial, +sizeof (dev->mdev.serial)); +usb_make_path (udev, dev->mdev.bus_info,sizeof (dev->mdev.bus_info)); + dev->mdev.hw_revision =le16_to_cpu (udev->descriptor.bcdDevice); +media_device_init (&dev->mdev); + + dev->vdev.mdev = &dev->mdev; +#endif +/* Parse the Video Class control descriptor. */ if (uvc_parse_control (dev) <0 ) { uvc_trace(UVC_TRACE_PROBE, "Unable to parse UVC "
@@ -2171,19 +2185,7 @@ static int uvc_probe(struct usb_interface *intf, "linux-uvc-devel mailing list.\n"); } -/* Initialize the media device and register the V4L2 device. */ -#ifdef CONFIG_MEDIA_CONTROLLER - dev->mdev.dev = &intf->dev; -strscpy (dev->mdev.model, dev->name,sizeof (dev->mdev.model)); -if (udev->serial) -strscpy (dev->mdev.serial, udev->serial, -sizeof (dev->mdev.serial)); -usb_make_path (udev, dev->mdev.bus_info,sizeof (dev->mdev.bus_info)); - dev->mdev.hw_revision =le16_to_cpu (udev->descriptor.bcdDevice); -media_device_init (&dev->mdev); - - dev->vdev.mdev = &dev->mdev; -#endif +/* Register the V4L2 device. */ if (v4l2_device_register (&intf->dev, &dev->vdev) <0 ) goto error;