upstream: [media] v4l: ti-vpe: zero out reserved fields in try_fmt
authorArchit Taneja <archit@ti.com>
Mon, 10 Mar 2014 07:19:02 +0000 (04:19 -0300)
committerChanho Park <chanho61.park@samsung.com>
Thu, 7 Aug 2014 05:26:47 +0000 (14:26 +0900)
Zero out the reserved formats in v4l2_pix_format_mplane and
v4l2_plane_pix_format members of the returned v4l2_format pointer when passed
through TRY_FMT ioctl.

This ensures that the user doesn't interpret the non-zero fields as some data
passed by the driver, and ensures compliance.

Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/platform/ti-vpe/vpe.c

index 10f37f6..b1a180f 100644 (file)
@@ -1429,6 +1429,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
                        pix->colorspace = V4L2_COLORSPACE_SMPTE240M;
        }
 
+       memset(pix->reserved, 0, sizeof(pix->reserved));
        for (i = 0; i < pix->num_planes; i++) {
                plane_fmt = &pix->plane_fmt[i];
                depth = fmt->vpdma_fmt[i]->depth;
@@ -1440,6 +1441,8 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
 
                plane_fmt->sizeimage =
                                (pix->height * pix->width * depth) >> 3;
+
+               memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved));
        }
 
        return 0;