Linux内核audio子系统soc_new_pcm_runtime()函数里的一个bug

Linux内核audio子系统soc_new_pcm_runtime()函数里的一个bug:


在分析qcom8550 Android-T kernel-5.15的audio子系统的代码时发现一个bug:

struct snd_soc_pcm_runtime {
    struct device *dev;
    ...
    struct snd_soc_component *components[]; /* CPU/Codec/Platform */
};

static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
	struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
{
	struct snd_soc_pcm_runtime *rtd;
	struct snd_soc_component *component;
	// 在分配rtd的内存空间时,sizeof(*component)是个bug,会导致多分配了一些内存空间,应该是sizeof(component),
	// 因为,snd_soc_pcm_runtime结构体里面,struct snd_soc_component *components[];
	// components是一个数组,数组里面保存的是指向snd_soc_component类型的指针。
	rtd = devm_kzalloc(dev,
			   sizeof(*rtd) +
			   sizeof(*component) * (dai_link->num_cpus +
						 dai_link->num_codecs +
						 dai_link->num_platforms),
			   GFP_KERNEL);	
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值