public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Vikash Garodia <quic_vgarodia@quicinc.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Stanimir Varbanov <stanimir.k.varbanov@gmail.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	<linux-media@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-hardening@vger.kernel.org>
Subject: Re: [PATCH 2/2][next] media: venus: hfi_cmds: Use struct_size() helper
Date: Thu, 25 May 2023 17:50:33 +0530	[thread overview]
Message-ID: <29a1cd75-4552-8026-c73a-6a4fefd8d2fd@quicinc.com> (raw)
In-Reply-To: <fd52d6ddce285474615e4bd96931ab12a0da8199.1684278538.git.gustavoars@kernel.org>


On 5/17/2023 4:44 AM, Gustavo A. R. Silva wrote:
> Prefer struct_size() over open-coded versions of idiom:
> 
> sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count
> 
> where count is the max number of items the flexible array is supposed to
> contain.
> 
> Link: https://github.com/KSPP/linux/issues/160
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

The patch looks good. As stated in previous patch, lets combine this into a
single series.

> ---
>  drivers/media/platform/qcom/venus/hfi_cmds.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/hfi_cmds.c b/drivers/media/platform/qcom/venus/hfi_cmds.c
> index 21d1b3c90dc0..3f74d518ad08 100644
> --- a/drivers/media/platform/qcom/venus/hfi_cmds.c
> +++ b/drivers/media/platform/qcom/venus/hfi_cmds.c
> @@ -209,8 +209,8 @@ int pkt_session_set_buffers(struct hfi_session_set_buffers_pkt *pkt,
>  		}
>  	} else {
>  		pkt->extradata_size = 0;
> -		pkt->shdr.hdr.size = sizeof(*pkt) +
> -			bd->num_buffers * sizeof(u32);
> +		pkt->shdr.hdr.size = struct_size(pkt, buffer_info,
> +						 bd->num_buffers);
>  		for (i = 0; i < pkt->num_buffers; i++)
>  			pkt->buffer_info[i] = bd->device_addr;
>  	}
> @@ -251,8 +251,8 @@ int pkt_session_unset_buffers(struct hfi_session_release_buffer_pkt *pkt,
>  
>  		pkt->extradata_size = 0;
>  		pkt->shdr.hdr.size =
> -				sizeof(struct hfi_session_set_buffers_pkt) +
> -				bd->num_buffers * sizeof(u32);
> +			struct_size((struct hfi_session_set_buffers_pkt *)0,
> +				    buffer_info, bd->num_buffers);
>  	}
>  
>  	pkt->response_req = bd->response_required;

      parent reply	other threads:[~2023-05-25 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 23:14 [PATCH 0/2][next] media: venus: hfi_cmds: Replace one-element array with flexible-array member Gustavo A. R. Silva
2023-05-16 23:14 ` [PATCH 1/2][next] " Gustavo A. R. Silva
2023-05-17 19:11   ` Kees Cook
2023-05-25 11:47   ` Vikash Garodia
2023-05-16 23:14 ` [PATCH 2/2][next] media: venus: hfi_cmds: Use struct_size() helper Gustavo A. R. Silva
2023-05-17 19:12   ` Kees Cook
2023-05-25 12:20   ` Vikash Garodia [this message]

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=29a1cd75-4552-8026-c73a-6a4fefd8d2fd@quicinc.com \
    --to=quic_vgarodia@quicinc.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=stanimir.k.varbanov@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox