media: v4l2-ioctl.c: zero reserved fields for S/TRY_FMT
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Sun, 10 Nov 2019 06:27:04 +0000 (07:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jan 2020 15:43:24 +0000 (16:43 +0100)
commit ee8951e56c0f960b9621636603a822811cef3158 upstream.

v4l2_vbi_format, v4l2_sliced_vbi_format and v4l2_sdr_format
have a reserved array at the end that should be zeroed by drivers
as per the V4L2 spec. Older drivers often do not do this, so just
handle this in the core.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/v4l2-core/v4l2-ioctl.c

index 7675b64..f75d892 100644 (file)
@@ -1548,12 +1548,12 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
        case V4L2_BUF_TYPE_VBI_CAPTURE:
                if (unlikely(!ops->vidioc_s_fmt_vbi_cap))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.vbi);
+               CLEAR_AFTER_FIELD(p, fmt.vbi.flags);
                return ops->vidioc_s_fmt_vbi_cap(file, fh, arg);
        case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
                if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_cap))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sliced);
+               CLEAR_AFTER_FIELD(p, fmt.sliced.io_size);
                return ops->vidioc_s_fmt_sliced_vbi_cap(file, fh, arg);
        case V4L2_BUF_TYPE_VIDEO_OUTPUT:
                if (unlikely(!ops->vidioc_s_fmt_vid_out))
@@ -1576,22 +1576,22 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
        case V4L2_BUF_TYPE_VBI_OUTPUT:
                if (unlikely(!ops->vidioc_s_fmt_vbi_out))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.vbi);
+               CLEAR_AFTER_FIELD(p, fmt.vbi.flags);
                return ops->vidioc_s_fmt_vbi_out(file, fh, arg);
        case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
                if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_out))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sliced);
+               CLEAR_AFTER_FIELD(p, fmt.sliced.io_size);
                return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg);
        case V4L2_BUF_TYPE_SDR_CAPTURE:
                if (unlikely(!ops->vidioc_s_fmt_sdr_cap))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sdr);
+               CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize);
                return ops->vidioc_s_fmt_sdr_cap(file, fh, arg);
        case V4L2_BUF_TYPE_SDR_OUTPUT:
                if (unlikely(!ops->vidioc_s_fmt_sdr_out))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sdr);
+               CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize);
                return ops->vidioc_s_fmt_sdr_out(file, fh, arg);
        case V4L2_BUF_TYPE_META_CAPTURE:
                if (unlikely(!ops->vidioc_s_fmt_meta_cap))
@@ -1635,12 +1635,12 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
        case V4L2_BUF_TYPE_VBI_CAPTURE:
                if (unlikely(!ops->vidioc_try_fmt_vbi_cap))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.vbi);
+               CLEAR_AFTER_FIELD(p, fmt.vbi.flags);
                return ops->vidioc_try_fmt_vbi_cap(file, fh, arg);
        case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
                if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_cap))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sliced);
+               CLEAR_AFTER_FIELD(p, fmt.sliced.io_size);
                return ops->vidioc_try_fmt_sliced_vbi_cap(file, fh, arg);
        case V4L2_BUF_TYPE_VIDEO_OUTPUT:
                if (unlikely(!ops->vidioc_try_fmt_vid_out))
@@ -1663,22 +1663,22 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
        case V4L2_BUF_TYPE_VBI_OUTPUT:
                if (unlikely(!ops->vidioc_try_fmt_vbi_out))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.vbi);
+               CLEAR_AFTER_FIELD(p, fmt.vbi.flags);
                return ops->vidioc_try_fmt_vbi_out(file, fh, arg);
        case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
                if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_out))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sliced);
+               CLEAR_AFTER_FIELD(p, fmt.sliced.io_size);
                return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg);
        case V4L2_BUF_TYPE_SDR_CAPTURE:
                if (unlikely(!ops->vidioc_try_fmt_sdr_cap))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sdr);
+               CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize);
                return ops->vidioc_try_fmt_sdr_cap(file, fh, arg);
        case V4L2_BUF_TYPE_SDR_OUTPUT:
                if (unlikely(!ops->vidioc_try_fmt_sdr_out))
                        break;
-               CLEAR_AFTER_FIELD(p, fmt.sdr);
+               CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize);
                return ops->vidioc_try_fmt_sdr_out(file, fh, arg);
        case V4L2_BUF_TYPE_META_CAPTURE:
                if (unlikely(!ops->vidioc_try_fmt_meta_cap))