Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4727830pxf; Tue, 23 Mar 2021 19:29:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBWZq5loKfer8DLizaxG7roogXA1ZWXbf8PmYX5npYcI5vZyhq/JkV7zBPTdbffxjXT2CT X-Received: by 2002:a50:ed83:: with SMTP id h3mr984178edr.140.1616552953721; Tue, 23 Mar 2021 19:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616552953; cv=none; d=google.com; s=arc-20160816; b=qMh3tnW8FIucHbJ9M7hf9T3IlzZfRQns9KEajedlaii5jnhbVG+0DWzTJS4Syufe9b haeXBmiAkwntoYeUsJWfPLvUnzUmMVC+GDsbXftLkQiey+X6/O7lj2UE4GnZmw3NjNUN NqqRAJNvyW4B744fZwJamM1ctKfmcnP+iI4j1mYAa92iMRqaE2JZMhmb0nGoC2mHYM6a L17IZS07P9b1l10XEUW1SrmR3DLbRbGuCC0M5UMBpETx2HlQz+7x5+D+4BW2sELJmN90 9Yo1Hx+B3u9DP6ulcikQJqLuP0jYF41TJBkm39Fd7UyL0BRySKAFt7idsBQRUcfrzS+7 lbjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=JegwZzQOphuUCh+7narQx8vTax8YJyw2tfOnPMz7jGo=; b=uzxnl8fhNKWgzZRpAqFIedBTBjc6e0ifnMewvuFqg7GYvmV5MWuyF4eq0eraK05g7Z ixVS5bSFpDNgUbgjaGsa/ff0uITrb2LIE8vUk7hnjLSPRaLdcYUwbp1C03UxCs1zMzf9 nE6aJnCvJeb1dIoGXgIqc5SeBj67yYeKgs1ZmJrbesJlDAKpFVaJuhm6tvP8vjCfW9zl ZZYeXhEv4nNGKmqSc0wRWtolucL4ErkKPPdIIEnrvUbmGCydAExSW9/fyWeN2xmBFytA oNdQ3kYU7Kcam69+tIdsoiT+TDfpF9vuvCwJpsZr88a5zylDetVVGBjY7u1Q+tWYgJ1Q 3pqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si650547ejb.220.2021.03.23.19.28.50; Tue, 23 Mar 2021 19:29:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232079AbhCWOYr (ORCPT + 99 others); Tue, 23 Mar 2021 10:24:47 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:34545 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232037AbhCWOY0 (ORCPT ); Tue, 23 Mar 2021 10:24:26 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lOhxF-0000jQ-Pj; Tue, 23 Mar 2021 14:24:21 +0000 From: Colin King To: Mirela Rabulea , NXP Linux Team , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Hans Verkuil , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] media: imx-jpeg: Pass the v4l2_jpeg_header header argument by reference Date: Tue, 23 Mar 2021 14:24:21 +0000 Message-Id: <20210323142421.348695-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently the header argument is being passed by value, so a copy of 256 byte structure on the stack is potentially occurring. Fix this by passing by reference to avoid any large stack copies. Addresses-Coverity: ("Big parameter passed by value") Fixes: 2db16c6ed72c ("media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder") Signed-off-by: Colin Ian King --- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c index adb1715c75d7..f13a8efc35ad 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c @@ -1114,21 +1114,21 @@ static int mxc_jpeg_valid_comp_id(struct device *dev, } static u32 mxc_jpeg_get_image_format(struct device *dev, - const struct v4l2_jpeg_header header) + const struct v4l2_jpeg_header *header) { int i; u32 fourcc = 0; for (i = 0; i < MXC_JPEG_NUM_FORMATS; i++) - if (mxc_formats[i].subsampling == header.frame.subsampling && - mxc_formats[i].nc == header.frame.num_components) { + if (mxc_formats[i].subsampling == header->frame.subsampling && + mxc_formats[i].nc == header->frame.num_components) { fourcc = mxc_formats[i].fourcc; break; } if (fourcc == 0) { dev_err(dev, "Could not identify image format nc=%d, subsampling=%d\n", - header.frame.num_components, - header.frame.subsampling); + header->frame.num_components, + header->frame.subsampling); return fourcc; } /* @@ -1137,7 +1137,7 @@ static u32 mxc_jpeg_get_image_format(struct device *dev, * ITU-T T.872 chapter 6.5.3 APP14 marker segment for colour encoding */ if (fourcc == V4L2_PIX_FMT_YUV24 || fourcc == V4L2_PIX_FMT_RGB24) { - if (header.app14_tf == V4L2_JPEG_APP14_TF_CMYK_RGB) + if (header->app14_tf == V4L2_JPEG_APP14_TF_CMYK_RGB) fourcc = V4L2_PIX_FMT_RGB24; else fourcc = V4L2_PIX_FMT_YUV24; @@ -1258,7 +1258,7 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, if (!mxc_jpeg_valid_comp_id(dev, psof, psos)) dev_warn(dev, "JPEG component ids should be 0-3 or 1-4"); - fourcc = mxc_jpeg_get_image_format(dev, header); + fourcc = mxc_jpeg_get_image_format(dev, &header); if (fourcc == 0) return -EINVAL; -- 2.30.2