Messages in this thread Patch in this message | | | From | Yu Liao <> | Subject | [PATCH -next] ASoC: SOF: topology: Fix memory leak in sof_control_load() | Date | Fri, 18 Mar 2022 10:16:16 +0800 |
| |
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> --- sound/soc/sof/topology.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 367fbe2d5b31..88f34f43d693 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -905,8 +905,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; -- 2.25.1
| |