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
This commit is contained in:
parent
56a6783442
commit
fe58139114
|
@ -679,13 +679,14 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = list_first_entry(&w->sources, struct snd_soc_dapm_path,
|
if (list_empty(&w->sources)) {
|
||||||
list_sink);
|
|
||||||
if (!path) {
|
|
||||||
dev_err(dapm->dev, "ASoC: mux %s has no paths\n", w->name);
|
dev_err(dapm->dev, "ASoC: mux %s has no paths\n", w->name);
|
||||||
return -EINVAL;
|
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);
|
ret = dapm_create_or_share_mixmux_kcontrol(w, 0, path);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue