=?gb18030?b?u9i4tKO6IFtQQVRDSF0gQXNvYzogY29yZTogZml4?==?gb18030?b?IHdyb25nIHNpemUga3phbGxvYyBmb3IgcnRkJ3Mg?==?gb18030?b?Y29tcG9uZW50cyBtZW1iZXI=?=

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



rtd's flexible arrays are typeof struct snd_soc_component *components[]  which means struct_pointer flexible arrays
sizeof(component) will allocate sizeof(struct snd_soc_component), but here only need sizeof(struct snd_soc_component *) 








------------------ 原始邮件 ------------------
发件人:                                                                                                                        "Amadeusz Sławiński"                                                                                    <amadeuszx.slawinski@xxxxxxxxxxxxxxx&gt;;
发送时间:&nbsp;2022年11月10日(星期四) 晚上7:02
收件人:&nbsp;"lishqchn"<lishqchn@xxxxxx&gt;;"perex"<perex@xxxxxxxx&gt;;"tiwai"<tiwai@xxxxxxxx&gt;;
抄送:&nbsp;"alsa-devel"<alsa-devel@xxxxxxxxxxxxxxxx&gt;;"broonie"<broonie@xxxxxxxxxx&gt;;"lgirdwood"<lgirdwood@xxxxxxxxx&gt;;"linux-kernel"<linux-kernel@xxxxxxxxxxxxxxx&gt;;
主题:&nbsp;Re: [PATCH] Asoc: core: fix wrong size kzalloc for rtd's components member



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




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux