aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/v4l2-dev.c')
-rw-r--r--drivers/media/video/v4l2-dev.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index c2122e53f051..b82778174eef 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -348,20 +348,14 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
348 int ret = -ENODEV; 348 int ret = -ENODEV;
349 349
350 if (vdev->fops->unlocked_ioctl) { 350 if (vdev->fops->unlocked_ioctl) {
351 bool locked = false; 351 struct mutex *lock = v4l2_ioctl_get_lock(vdev, cmd);
352 352
353 if (vdev->lock) { 353 if (lock && mutex_lock_interruptible(lock))
354 /* always lock unless the cmd is marked as "don't use lock" */ 354 return -ERESTARTSYS;
355 locked = !v4l2_is_known_ioctl(cmd) ||
356 !test_bit(_IOC_NR(cmd), vdev->disable_locking);
357
358 if (locked && mutex_lock_interruptible(vdev->lock))
359 return -ERESTARTSYS;
360 }
361 if (video_is_registered(vdev)) 355 if (video_is_registered(vdev))
362 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); 356 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
363 if (locked) 357 if (lock)
364 mutex_unlock(vdev->lock); 358 mutex_unlock(lock);
365 } else if (vdev->fops->ioctl) { 359 } else if (vdev->fops->ioctl) {
366 /* This code path is a replacement for the BKL. It is a major 360 /* This code path is a replacement for the BKL. It is a major
367 * hack but it will have to do for those drivers that are not 361 * hack but it will have to do for those drivers that are not