summaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/uvc/uvc_driver.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-04-27 19:28:26 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-06-15 17:57:24 -0300
commita087ce704b802becbb4b0f2a20f2cb3f6911802e (patch)
tree6cfa3f4ac4ef03bc7f7cc5fe4180a956f470213b /drivers/media/usb/uvc/uvc_driver.c
parent163f1e93e995048b894c5fc86a6034d16beed740 (diff)
downloadtalos-obmc-linux-a087ce704b802becbb4b0f2a20f2cb3f6911802e.tar.gz
talos-obmc-linux-a087ce704b802becbb4b0f2a20f2cb3f6911802e.zip
[media] media-device: dynamically allocate struct media_devnode
struct media_devnode is currently embedded at struct media_device. While this works fine during normal usage, it leads to a race condition during devnode unregister. the problem is that drivers assume that, after calling media_device_unregister(), the struct that contains media_device can be freed. This is not true, as it can't be freed until userspace closes all opened /dev/media devnodes. In other words, if the media devnode is still open, and media_device gets freed, any call to an ioctl will make the core to try to access struct media_device, with will cause an use-after-free and even GPF. Fix this by dynamically allocating the struct media_devnode and only freeing it when it is safe. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/usb/uvc/uvc_driver.c')
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 451e84e962e2..302e284a95eb 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1674,7 +1674,7 @@ static void uvc_delete(struct uvc_device *dev)
if (dev->vdev.dev)
v4l2_device_unregister(&dev->vdev);
#ifdef CONFIG_MEDIA_CONTROLLER
- if (media_devnode_is_registered(&dev->mdev.devnode))
+ if (media_devnode_is_registered(dev->mdev.devnode))
media_device_unregister(&dev->mdev);
media_device_cleanup(&dev->mdev);
#endif
OpenPOWER on IntegriCloud