Skip to content

Commit 9b91d0e

Browse files
yuliao0214broonie
authored andcommitted
ASoC: SOF: topology: Fix memory leak in sof_control_load()
scontrol doesn't get freed when kstrdup returns NULL. Fix by free iscontrol in that case. scontrol = kzalloc(sizeof(*scontrol), GFP_KERNEL); if (!scontrol) return -ENOMEM; scontrol->name = kstrdup(hdr->name, GFP_KERNEL); if (!scontrol->name) return -ENOMEM; Signed-off-by: Yu Liao <liaoyu15@huawei.com> Link: https://lore.kernel.org/r/20220318021616.2599630-1-liaoyu15@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2074461 commit 9b91d0e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

sound/soc/sof/topology.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,10 @@ static int sof_control_load(struct snd_soc_component *scomp, int index,
904904
return -ENOMEM;
905905

906906
scontrol->name = kstrdup(hdr->name, GFP_KERNEL);
907-
if (!scontrol->name)
907+
if (!scontrol->name) {
908+
kfree(scontrol);
908909
return -ENOMEM;
910+
}
909911

910912
scontrol->scomp = scomp;
911913
scontrol->access = kc->access;

0 commit comments

Comments
 (0)