From b3cacc62037cb03a27c3e111b0cdebdcac89e93e Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 19 Jul 2018 17:27:13 +0800 Subject: [PATCH] [SQUASHME]ASoC: sof: topology: fix memleak when errror happen Add kfree function when other error happens. Signed-off-by: Pan Xiuli --- sound/soc/sof/topology.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 143a191b381ad0..2ac70900821480 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -721,6 +721,7 @@ static int sof_control_load(struct snd_soc_component *scomp, int index, default: dev_warn(sdev->dev, "control type not supported %d:%d:%d\n", hdr->ops.get, hdr->ops.put, hdr->ops.info); + kfree(scontrol); return 0; } @@ -1255,8 +1256,10 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, case snd_soc_dapm_dai_in: case snd_soc_dapm_dai_out: dai = kzalloc(sizeof(*dai), GFP_KERNEL); - if (!dai) + if (!dai) { + kfree(swidget); return -ENOMEM; + } ret = sof_widget_load_dai(scomp, index, swidget, tw, &reply, dai); @@ -1320,6 +1323,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, "error: DSP failed to add widget id %d type %d name : %s stream %s reply %d\n", tw->shift, swidget->id, tw->name, tw->sname ? tw->sname : "none", reply.rhdr.error); + kfree(swidget); return ret; }