public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: lishqchn <lishqchn@qq.com>, perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
	lgirdwood@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Asoc: core: fix wrong size kzalloc for rtd's components member
Date: Thu, 10 Nov 2022 12:02:53 +0100	[thread overview]
Message-ID: <8039aad2-3d6f-153f-bf23-892c3804b0fa@linux.intel.com> (raw)
In-Reply-To: <tencent_59850BB028662B6F2D49D7F3624AB84CCF05@qq.com>

On 11/8/2022 5:24 AM, lishqchn wrote:
> The actual space for struct snd_soc_component has been allocated by
> snd_soc_register_component, here rtd's components are pointers to
> components, I replace the base size from *component to component.
> 
> Signed-off-by: lishqchn <lishqchn@qq.com>
> ---
>   sound/soc/soc-core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index a6d6d10cd471..d21e0284b2aa 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -459,7 +459,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
>   	 */
>   	rtd = devm_kzalloc(dev,
>   			   sizeof(*rtd) +
> -			   sizeof(*component) * (dai_link->num_cpus +
> +			   sizeof(component) * (dai_link->num_cpus +
>   						 dai_link->num_codecs +
>   						 dai_link->num_platforms),
>   			   GFP_KERNEL);

Can't struct_size macro be used instead, it is meant to be used when 
calculating size of structs containing flexible arrays at the end?


       reply	other threads:[~2022-11-10 11:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <tencent_59850BB028662B6F2D49D7F3624AB84CCF05@qq.com>
2022-11-10 11:02 ` Amadeusz Sławiński [this message]
2022-11-15 16:42 ` [PATCH] Asoc: core: fix wrong size kzalloc for rtd's components member Mark Brown

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=8039aad2-3d6f-153f-bf23-892c3804b0fa@linux.intel.com \
    --to=amadeuszx.slawinski@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lishqchn@qq.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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