From d04794da9649ab49421a4f942937fbd52896bd3f Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 2 Mar 2023 13:57:30 +0100 Subject: [PATCH] media: v4l2-core: zero field base in struct v4l2_framebuffer Make sure this field is always 0 since destructive overlays are no longer supported. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 7 ++----- drivers/media/v4l2-core/v4l2-ioctl.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index e7baa2880eeb..f3bed37859a2 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -587,14 +587,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; } diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 2af826f97b4b..caeed2e62b71 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -2060,6 +2060,15 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, return ops->vidioc_s_hw_freq_seek(file, fh, p); } +static int v4l_s_fbuf(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_framebuffer *p = arg; + + p->base = NULL; + return ops->vidioc_s_fbuf(file, fh, p); +} + static int v4l_overlay(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { @@ -2779,7 +2788,6 @@ struct v4l2_ioctl_info { } DEFINE_V4L_STUB_FUNC(g_fbuf) -DEFINE_V4L_STUB_FUNC(s_fbuf) DEFINE_V4L_STUB_FUNC(expbuf) DEFINE_V4L_STUB_FUNC(g_std) DEFINE_V4L_STUB_FUNC(g_audio) @@ -2813,7 +2821,7 @@ static const struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_REQBUFS, v4l_reqbufs, v4l_print_requestbuffers, INFO_FL_PRIO | INFO_FL_QUEUE), IOCTL_INFO(VIDIOC_QUERYBUF, v4l_querybuf, v4l_print_buffer, INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_buffer, length)), IOCTL_INFO(VIDIOC_G_FBUF, v4l_stub_g_fbuf, v4l_print_framebuffer, 0), - IOCTL_INFO(VIDIOC_S_FBUF, v4l_stub_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO), + IOCTL_INFO(VIDIOC_S_FBUF, v4l_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_OVERLAY, v4l_overlay, v4l_print_u32, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, INFO_FL_QUEUE), IOCTL_INFO(VIDIOC_EXPBUF, v4l_stub_expbuf, v4l_print_exportbuffer, INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_exportbuffer, flags)),