From patchwork Fri Nov 23 17:19:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10696227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 51A561750 for ; Fri, 23 Nov 2018 17:20:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4077D2BF2A for ; Fri, 23 Nov 2018 17:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 325042C2A5; Fri, 23 Nov 2018 17:20:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F18992BF2A for ; Fri, 23 Nov 2018 17:20:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440809AbeKXEFU (ORCPT ); Fri, 23 Nov 2018 23:05:20 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60986 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391344AbeKXEFU (ORCPT ); Fri, 23 Nov 2018 23:05:20 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id EDB332722B0 From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , Ezequiel Garcia Subject: [PATCH] v4l2-ioctl: Zero v4l2_pix_format_mplane reserved fields Date: Fri, 23 Nov 2018 14:19:58 -0300 Message-Id: <20181123171958.17614-1-ezequiel@collabora.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the core set the reserved fields to zero in v4l2_pix_format_mplane and v4l2_plane_pix_format structs, for _MPLANE queue types. Moving this to the core avoids having to do so in each and every driver. Suggested-by: Tomasz Figa Signed-off-by: Ezequiel Garcia --- drivers/media/v4l2-core/v4l2-ioctl.c | 51 ++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 10b862dcbd86..3858fffc3e68 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1420,6 +1420,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, { struct v4l2_format *p = arg; int ret = check_fmt(file, p->type); + int i; if (ret) return ret; @@ -1458,7 +1459,13 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; return ret; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: - return ops->vidioc_g_fmt_vid_cap_mplane(file, fh, arg); + ret = ops->vidioc_g_fmt_vid_cap_mplane(file, fh, arg); + memset(p->fmt.pix_mp.reserved, 0, + sizeof(p->fmt.pix_mp.reserved)); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + memset(p->fmt.pix_mp.plane_fmt[i].reserved, 0, + sizeof(p->fmt.pix_mp.plane_fmt[i].reserved)); + return ret; case V4L2_BUF_TYPE_VIDEO_OVERLAY: return ops->vidioc_g_fmt_vid_overlay(file, fh, arg); case V4L2_BUF_TYPE_VBI_CAPTURE: @@ -1474,7 +1481,13 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; return ret; case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: - return ops->vidioc_g_fmt_vid_out_mplane(file, fh, arg); + ret = ops->vidioc_g_fmt_vid_out_mplane(file, fh, arg); + memset(p->fmt.pix_mp.reserved, 0, + sizeof(p->fmt.pix_mp.reserved)); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + memset(p->fmt.pix_mp.plane_fmt[i].reserved, 0, + sizeof(p->fmt.pix_mp.plane_fmt[i].reserved)); + return ret; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: return ops->vidioc_g_fmt_vid_out_overlay(file, fh, arg); case V4L2_BUF_TYPE_VBI_OUTPUT: @@ -1512,6 +1525,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct v4l2_format *p = arg; struct video_device *vfd = video_devdata(file); int ret = check_fmt(file, p->type); + int i; if (ret) return ret; @@ -1536,7 +1550,13 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_s_fmt_vid_cap_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); - return ops->vidioc_s_fmt_vid_cap_mplane(file, fh, arg); + ret = ops->vidioc_s_fmt_vid_cap_mplane(file, fh, arg); + memset(p->fmt.pix_mp.reserved, 0, + sizeof(p->fmt.pix_mp.reserved)); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + memset(p->fmt.pix_mp.plane_fmt[i].reserved, 0, + sizeof(p->fmt.pix_mp.plane_fmt[i].reserved)); + return ret; case V4L2_BUF_TYPE_VIDEO_OVERLAY: if (unlikely(!ops->vidioc_s_fmt_vid_overlay)) break; @@ -1564,7 +1584,13 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_s_fmt_vid_out_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); - return ops->vidioc_s_fmt_vid_out_mplane(file, fh, arg); + ret = ops->vidioc_s_fmt_vid_out_mplane(file, fh, arg); + memset(p->fmt.pix_mp.reserved, 0, + sizeof(p->fmt.pix_mp.reserved)); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + memset(p->fmt.pix_mp.plane_fmt[i].reserved, 0, + sizeof(p->fmt.pix_mp.plane_fmt[i].reserved)); + return ret; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: if (unlikely(!ops->vidioc_s_fmt_vid_out_overlay)) break; @@ -1604,6 +1630,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, { struct v4l2_format *p = arg; int ret = check_fmt(file, p->type); + int i; if (ret) return ret; @@ -1623,7 +1650,13 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); - return ops->vidioc_try_fmt_vid_cap_mplane(file, fh, arg); + ret = ops->vidioc_try_fmt_vid_cap_mplane(file, fh, arg); + memset(p->fmt.pix_mp.reserved, 0, + sizeof(p->fmt.pix_mp.reserved)); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + memset(p->fmt.pix_mp.plane_fmt[i].reserved, 0, + sizeof(p->fmt.pix_mp.plane_fmt[i].reserved)); + return ret; case V4L2_BUF_TYPE_VIDEO_OVERLAY: if (unlikely(!ops->vidioc_try_fmt_vid_overlay)) break; @@ -1651,7 +1684,13 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_try_fmt_vid_out_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); - return ops->vidioc_try_fmt_vid_out_mplane(file, fh, arg); + ret = ops->vidioc_try_fmt_vid_out_mplane(file, fh, arg); + memset(p->fmt.pix_mp.reserved, 0, + sizeof(p->fmt.pix_mp.reserved)); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + memset(p->fmt.pix_mp.plane_fmt[i].reserved, 0, + sizeof(p->fmt.pix_mp.plane_fmt[i].reserved)); + return ret; case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: if (unlikely(!ops->vidioc_try_fmt_vid_out_overlay)) break;