All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mirela Rabulea <mirela.rabulea@nxp.com>
To: dl-linux-imx <linux-imx@nxp.com>,
	"colin.king@canonical.com" <colin.king@canonical.com>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"festevam@gmail.com" <festevam@gmail.com>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [EXT] [PATCH][next] media: imx-jpeg: Pass the v4l2_jpeg_header header argument by reference
Date: Sat, 27 Mar 2021 14:32:49 +0000	[thread overview]
Message-ID: <746d11c3f0feb79f0e8fdc16d5bdead3795f1f3e.camel@nxp.com> (raw)
In-Reply-To: <20210323142421.348695-1-colin.king@canonical.com>

Hi,

On Tue, 2021-03-23 at 14:24 +0000, Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>
> ---
>  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
> 
Thanks for the patch.

Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>

Regards,
Mirela

WARNING: multiple messages have this Message-ID (diff)
From: Mirela Rabulea <mirela.rabulea@nxp.com>
To: dl-linux-imx <linux-imx@nxp.com>,
	"colin.king@canonical.com" <colin.king@canonical.com>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"festevam@gmail.com" <festevam@gmail.com>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
	 "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [EXT] [PATCH][next] media: imx-jpeg: Pass the v4l2_jpeg_header header argument by reference
Date: Sat, 27 Mar 2021 14:32:49 +0000	[thread overview]
Message-ID: <746d11c3f0feb79f0e8fdc16d5bdead3795f1f3e.camel@nxp.com> (raw)
In-Reply-To: <20210323142421.348695-1-colin.king@canonical.com>

Hi,

On Tue, 2021-03-23 at 14:24 +0000, Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>
> ---
>  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
> 
Thanks for the patch.

Reviewed-by: Mirela Rabulea <mirela.rabulea@nxp.com>

Regards,
Mirela
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-03-27 14:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 14:24 [PATCH][next] media: imx-jpeg: Pass the v4l2_jpeg_header header argument by reference Colin King
2021-03-23 14:24 ` Colin King
2021-03-27 14:32 ` Mirela Rabulea [this message]
2021-03-27 14:32   ` [EXT] " Mirela Rabulea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=746d11c3f0feb79f0e8fdc16d5bdead3795f1f3e.camel@nxp.com \
    --to=mirela.rabulea@nxp.com \
    --cc=colin.king@canonical.com \
    --cc=festevam@gmail.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.