aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/videodev.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index bf12b5f850e2..aca36dec6746 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -2023,9 +2023,13 @@ EXPORT_SYMBOL(video_ioctl2);
2023static int get_index(struct video_device *vdev, int num) 2023static int get_index(struct video_device *vdev, int num)
2024{ 2024{
2025 u32 used = 0; 2025 u32 used = 0;
2026 const unsigned max_index = sizeof(used) * 8 - 1;
2026 int i; 2027 int i;
2027 2028
2028 if (num >= 32) { 2029 /* Currently a single v4l driver instance cannot create more than
2030 32 devices.
2031 Increase to u64 or an array of u32 if more are needed. */
2032 if (num > max_index) {
2029 printk(KERN_ERR "videodev: %s num is too large\n", __func__); 2033 printk(KERN_ERR "videodev: %s num is too large\n", __func__);
2030 return -EINVAL; 2034 return -EINVAL;
2031 } 2035 }
@@ -2045,7 +2049,7 @@ static int get_index(struct video_device *vdev, int num)
2045 } 2049 }
2046 2050
2047 i = ffz(used); 2051 i = ffz(used);
2048 return i >= 32 ? -ENFILE : i; 2052 return i > max_index ? -ENFILE : i;
2049} 2053}
2050 2054
2051static const struct file_operations video_fops; 2055static const struct file_operations video_fops;