diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-08-01 20:30:38 +0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-01 22:25:16 +0400 |
commit | fe581391147cb3d738d961d0f1233d91a9e1113c (patch) | |
tree | cadab7c9e8b6913e9373c6fa6ae35981385c8221 /sound/soc | |
parent | 56a678344273fd63f8ade26876283a2586a9bf3a (diff) | |
download | linux-fe581391147cb3d738d961d0f1233d91a9e1113c.tar.xz |
ASoC: dapm: Fix empty list check in dapm_new_mux()
list_first_entry() will always return a valid pointer, even if the list is
empty. So the check whether path is NULL will always be false. So we end up
calling dapm_create_or_share_mixmux_kcontrol() with a path struct that points
right in the middle of the widget struct and by trying to modify the path the
widgets memory will become corrupted. Fix this by using list_emtpy() to check if
the widget doesn't have any paths.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Cc: stable@vger.kernel.org
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/soc-dapm.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index bd16010441cc..4375c9f2b791 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -679,13 +679,14 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w) return -EINVAL; } - path = list_first_entry(&w->sources, struct snd_soc_dapm_path, - list_sink); - if (!path) { + if (list_empty(&w->sources)) { dev_err(dapm->dev, "ASoC: mux %s has no paths\n", w->name); return -EINVAL; } + path = list_first_entry(&w->sources, struct snd_soc_dapm_path, + list_sink); + ret = dapm_create_or_share_mixmux_kcontrol(w, 0, path); if (ret < 0) return ret; |