Commit e50b1e06 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: dapm: Lock during userspace access

The DAPM lock must be held when accessing the DAPM graph status through
sysfs or debugfs, otherwise concurrent changes to the graph can result in
undefined behaviour.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
parent ffacb48e
...@@ -1952,6 +1952,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file, ...@@ -1952,6 +1952,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct snd_soc_dapm_widget *w = file->private_data; struct snd_soc_dapm_widget *w = file->private_data;
struct snd_soc_card *card = w->dapm->card;
char *buf; char *buf;
int in, out; int in, out;
ssize_t ret; ssize_t ret;
...@@ -1961,6 +1962,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file, ...@@ -1961,6 +1962,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
mutex_lock(&card->dapm_mutex);
/* Supply widgets are not handled by is_connected_{input,output}_ep() */ /* Supply widgets are not handled by is_connected_{input,output}_ep() */
if (w->is_supply) { if (w->is_supply) {
in = 0; in = 0;
...@@ -2007,6 +2010,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file, ...@@ -2007,6 +2010,8 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
p->sink->name); p->sink->name);
} }
mutex_unlock(&card->dapm_mutex);
ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
kfree(buf); kfree(buf);
...@@ -2281,11 +2286,15 @@ static ssize_t dapm_widget_show(struct device *dev, ...@@ -2281,11 +2286,15 @@ static ssize_t dapm_widget_show(struct device *dev,
struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
int i, count = 0; int i, count = 0;
mutex_lock(&rtd->card->dapm_mutex);
for (i = 0; i < rtd->num_codecs; i++) { for (i = 0; i < rtd->num_codecs; i++) {
struct snd_soc_codec *codec = rtd->codec_dais[i]->codec; struct snd_soc_codec *codec = rtd->codec_dais[i]->codec;
count += dapm_widget_show_codec(codec, buf + count); count += dapm_widget_show_codec(codec, buf + count);
} }
mutex_unlock(&rtd->card->dapm_mutex);
return count; return count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment