diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 6b84c3413e83..ab8ba19cad73 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -2153,13 +2153,17 @@ static int em28xx_v4l2_open(struct file *filp) return -EINVAL; } + if (mutex_lock_interruptible(&dev->lock)) + return -ERESTARTSYS; + if (!dev->v4l2) { + mutex_unlock(&dev->lock); + return -ENOMEM; + } + em28xx_videodbg("open dev=%s type=%s users=%d\n", video_device_node_name(vdev), v4l2_type_names[fh_type], v4l2->users); - if (mutex_lock_interruptible(&dev->lock)) - return -ERESTARTSYS; - ret = v4l2_fh_open(filp); if (ret) { dev_err(&dev->intf->dev, @@ -2885,6 +2889,7 @@ static int em28xx_v4l2_init(struct em28xx *dev) return 0; unregister_dev: + pr_info("debug: em28xx_v4l2_init() &v4l2->vdev: %px\n", &v4l2->vdev); if (video_is_registered(&v4l2->radio_dev)) { dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index a593ea0598b5..2ad106ede7f0 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -417,6 +417,7 @@ static int v4l2_open(struct inode *inode, struct file *filp) } /* and increase the device refcount */ video_get(vdev); + pr_info("debug: v4l2_open() vdev: %px\n", vdev); mutex_unlock(&videodev_lock); if (vdev->fops->open) { if (video_is_registered(vdev)) @@ -1086,6 +1087,7 @@ void video_unregister_device(struct video_device *vdev) */ clear_bit(V4L2_FL_REGISTERED, &vdev->flags); mutex_unlock(&videodev_lock); + pr_info("debug: video_unregister_device() vdev: %px\n", vdev); device_unregister(&vdev->dev); } EXPORT_SYMBOL(video_unregister_device);