summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorWenwen Wang2019-07-22 15:57:44 +0200
committerMark Brown2019-07-22 18:33:38 +0200
commit45004d66f2a28d78f543fb2ffbc133e31dc2d162 (patch)
treeca55e1411f9c37fe844588b04d9d90e114109edc /sound
parentASoC: SOF: use __u32 instead of uint32_t in uapi headers (diff)
downloadkernel-qcow2-linux-45004d66f2a28d78f543fb2ffbc133e31dc2d162.tar.gz
kernel-qcow2-linux-45004d66f2a28d78f543fb2ffbc133e31dc2d162.tar.xz
kernel-qcow2-linux-45004d66f2a28d78f543fb2ffbc133e31dc2d162.zip
ASoC: dapm: fix a memory leak bug
In snd_soc_dapm_new_control_unlocked(), a kernel buffer is allocated in dapm_cnew_widget() to hold the new dapm widget. Then, different actions are taken according to the id of the widget, i.e., 'w->id'. If any failure occurs during this process, snd_soc_dapm_new_control_unlocked() should be terminated by going to the 'request_failed' label. However, the allocated kernel buffer is not freed on this code path, leading to a memory leak bug. To fix the above issue, free the buffer before returning from snd_soc_dapm_new_control_unlocked() through the 'request_failed' label. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Link: https://lore.kernel.org/r/1563803864-2809-1-git-send-email-wang6495@umn.edu Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-dapm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 9cd87e47ee8f..656cb5cd9cd8 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3704,6 +3704,8 @@ request_failed:
dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n",
w->name, ret);
+ kfree_const(w->sname);
+ kfree(w);
return ERR_PTR(ret);
}