summaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorYu Liao <liaoyu15@huawei.com>2022-03-18 03:16:16 +0100
committerMark Brown <broonie@kernel.org>2022-04-07 19:29:37 +0200
commit9b91d0ece22b9ab37fc185511c7f992e51c93d6e (patch)
treeae5b1f2074283728d81faea0e92a47903b17e225 /sound/soc
parentASoC: SOF: topology: cleanup dailinks on widget unload (diff)
downloadlinux-9b91d0ece22b9ab37fc185511c7f992e51c93d6e.tar.xz
linux-9b91d0ece22b9ab37fc185511c7f992e51c93d6e.zip
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>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/sof/topology.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 5953d1050cc9..3e5b319b44c7 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -904,8 +904,10 @@ static int sof_control_load(struct snd_soc_component *scomp, int index,
return -ENOMEM;
scontrol->name = kstrdup(hdr->name, GFP_KERNEL);
- if (!scontrol->name)
+ if (!scontrol->name) {
+ kfree(scontrol);
return -ENOMEM;
+ }
scontrol->scomp = scomp;
scontrol->access = kc->access;