diff options
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-compat-ioctl32.c')
| -rw-r--r-- | drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 106 |
1 files changed, 25 insertions, 81 deletions
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index 55c26e7d370e..2c88e1175a10 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -8,7 +8,7 @@ * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz) * Copyright (C) 2005 Philippe De Muyter (phdm@macqel.be) - * Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl> + * Copyright (C) 2008 Hans Verkuil <hverkuil@kernel.org> * * These routines maintain argument size conversion between 32bit and 64bit * ioctls. @@ -38,18 +38,13 @@ * data to the routine. */ -struct v4l2_clip32 { - struct v4l2_rect c; - compat_caddr_t next; -}; - struct v4l2_window32 { struct v4l2_rect w; __u32 field; /* enum v4l2_field */ __u32 chromakey; - compat_caddr_t clips; /* actually struct v4l2_clip32 * */ - __u32 clipcount; - compat_caddr_t bitmap; + compat_caddr_t clips; /* always NULL */ + __u32 clipcount; /* always 0 */ + compat_caddr_t bitmap; /* always NULL */ __u8 global_alpha; }; @@ -65,17 +60,12 @@ static int get_v4l2_window32(struct v4l2_window *p64, .w = w32.w, .field = w32.field, .chromakey = w32.chromakey, - .clips = (void __force *)compat_ptr(w32.clips), - .clipcount = w32.clipcount, - .bitmap = compat_ptr(w32.bitmap), + .clips = NULL, + .clipcount = 0, + .bitmap = NULL, .global_alpha = w32.global_alpha, }; - if (p64->clipcount > 2048) - return -EINVAL; - if (!p64->clipcount) - p64->clips = NULL; - return 0; } @@ -89,16 +79,13 @@ static int put_v4l2_window32(struct v4l2_window *p64, .w = p64->w, .field = p64->field, .chromakey = p64->chromakey, - .clips = (uintptr_t)p64->clips, - .clipcount = p64->clipcount, - .bitmap = ptr_to_compat(p64->bitmap), + .clips = 0, + .clipcount = 0, + .bitmap = 0, .global_alpha = p64->global_alpha, }; - /* copy everything except the clips pointer */ - if (copy_to_user(p32, &w32, offsetof(struct v4l2_window32, clips)) || - copy_to_user(&p32->clipcount, &w32.clipcount, - sizeof(w32) - offsetof(struct v4l2_window32, clipcount))) + if (copy_to_user(p32, &w32, sizeof(w32))) return -EFAULT; return 0; @@ -129,6 +116,9 @@ struct v4l2_format32 { * @flags: additional buffer management attributes (ignored unless the * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability and * configured for MMAP streaming I/O). + * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set + * this field indicate the maximum possible number of buffers + * for this queue. * @reserved: future extensions */ struct v4l2_create_buffers32 { @@ -138,7 +128,8 @@ struct v4l2_create_buffers32 { struct v4l2_format32 format; __u32 capabilities; __u32 flags; - __u32 reserved[6]; + __u32 max_num_buffers; + __u32 reserved[5]; }; static int get_v4l2_format32(struct v4l2_format *p64, @@ -188,6 +179,9 @@ static int get_v4l2_create32(struct v4l2_create_buffers *p64, return -EFAULT; if (copy_from_user(&p64->flags, &p32->flags, sizeof(p32->flags))) return -EFAULT; + if (copy_from_user(&p64->max_num_buffers, &p32->max_num_buffers, + sizeof(p32->max_num_buffers))) + return -EFAULT; return get_v4l2_format32(&p64->format, &p32->format); } @@ -234,6 +228,7 @@ static int put_v4l2_create32(struct v4l2_create_buffers *p64, offsetof(struct v4l2_create_buffers32, format)) || put_user(p64->capabilities, &p32->capabilities) || put_user(p64->flags, &p32->flags) || + put_user(p64->max_num_buffers, &p32->max_num_buffers) || copy_to_user(p32->reserved, p64->reserved, sizeof(p64->reserved))) return -EFAULT; return put_v4l2_format32(&p64->format, &p32->format); @@ -600,14 +595,11 @@ struct v4l2_framebuffer32 { static int get_v4l2_framebuffer32(struct v4l2_framebuffer *p64, struct v4l2_framebuffer32 __user *p32) { - compat_caddr_t tmp; - - if (get_user(tmp, &p32->base) || - get_user(p64->capability, &p32->capability) || + if (get_user(p64->capability, &p32->capability) || get_user(p64->flags, &p32->flags) || copy_from_user(&p64->fmt, &p32->fmt, sizeof(p64->fmt))) return -EFAULT; - p64->base = (void __force *)compat_ptr(tmp); + p64->base = NULL; return 0; } @@ -680,15 +672,12 @@ struct v4l2_ext_control32 { static inline bool ctrl_is_pointer(struct file *file, u32 id) { struct video_device *vdev = video_devdata(file); - struct v4l2_fh *fh = NULL; + struct v4l2_fh *fh = file_to_v4l2_fh(file); struct v4l2_ctrl_handler *hdl = NULL; struct v4l2_query_ext_ctrl qec = { id }; const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops; - if (test_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags)) - fh = file->private_data; - - if (fh && fh->ctrl_handler) + if (fh->ctrl_handler) hdl = fh->ctrl_handler; else if (vdev->ctrl_handler) hdl = vdev->ctrl_handler; @@ -702,7 +691,7 @@ static inline bool ctrl_is_pointer(struct file *file, u32 id) if (!ops || !ops->vidioc_query_ext_ctrl) return false; - return !ops->vidioc_query_ext_ctrl(file, fh, &qec) && + return !ops->vidioc_query_ext_ctrl(file, NULL, &qec) && (qec.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD); } @@ -1043,29 +1032,6 @@ int v4l2_compat_get_array_args(struct file *file, void *mbuf, memset(mbuf, 0, array_size); switch (cmd) { - case VIDIOC_G_FMT32: - case VIDIOC_S_FMT32: - case VIDIOC_TRY_FMT32: { - struct v4l2_format *f64 = arg; - struct v4l2_clip *c64 = mbuf; - struct v4l2_clip32 __user *c32 = user_ptr; - u32 clipcount = f64->fmt.win.clipcount; - - if ((f64->type != V4L2_BUF_TYPE_VIDEO_OVERLAY && - f64->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY) || - clipcount == 0) - return 0; - if (clipcount > 2048) - return -EINVAL; - while (clipcount--) { - if (copy_from_user(c64, c32, sizeof(c64->c))) - return -EFAULT; - c64->next = NULL; - c64++; - c32++; - } - break; - } #ifdef CONFIG_COMPAT_32BIT_TIME case VIDIOC_QUERYBUF32_TIME32: case VIDIOC_QBUF32_TIME32: @@ -1136,28 +1102,6 @@ int v4l2_compat_put_array_args(struct file *file, void __user *user_ptr, int err = 0; switch (cmd) { - case VIDIOC_G_FMT32: - case VIDIOC_S_FMT32: - case VIDIOC_TRY_FMT32: { - struct v4l2_format *f64 = arg; - struct v4l2_clip *c64 = mbuf; - struct v4l2_clip32 __user *c32 = user_ptr; - u32 clipcount = f64->fmt.win.clipcount; - - if ((f64->type != V4L2_BUF_TYPE_VIDEO_OVERLAY && - f64->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY) || - clipcount == 0) - return 0; - if (clipcount > 2048) - return -EINVAL; - while (clipcount--) { - if (copy_to_user(c32, c64, sizeof(c64->c))) - return -EFAULT; - c64++; - c32++; - } - break; - } #ifdef CONFIG_COMPAT_32BIT_TIME case VIDIOC_QUERYBUF32_TIME32: case VIDIOC_QBUF32_TIME32: |
