Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754784AbbHNSRy (ORCPT ); Fri, 14 Aug 2015 14:17:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51191 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932511AbbHNRnS (ORCPT ); Fri, 14 Aug 2015 13:43:18 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars-Peter Clausen , Mark Brown Subject: [PATCH 4.1 48/84] ASoC: dapm: Lock during userspace access Date: Fri, 14 Aug 2015 10:42:16 -0700 Message-Id: <20150814174211.671402908@linuxfoundation.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <20150814174210.214822912@linuxfoundation.org> References: <20150814174210.214822912@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2015 Lines: 71 4.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lars-Peter Clausen commit e50b1e06b79e9d51efbff9627b4dd407184ef43f upstream. 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: Lars-Peter Clausen Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-dapm.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1811,6 +1811,7 @@ static ssize_t dapm_widget_power_read_fi size_t count, loff_t *ppos) { struct snd_soc_dapm_widget *w = file->private_data; + struct snd_soc_card *card = w->dapm->card; char *buf; int in, out; ssize_t ret; @@ -1820,6 +1821,8 @@ static ssize_t dapm_widget_power_read_fi if (!buf) return -ENOMEM; + mutex_lock(&card->dapm_mutex); + /* Supply widgets are not handled by is_connected_{input,output}_ep() */ if (w->is_supply) { in = 0; @@ -1866,6 +1869,8 @@ static ssize_t dapm_widget_power_read_fi p->sink->name); } + mutex_unlock(&card->dapm_mutex); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); kfree(buf); @@ -2140,11 +2145,15 @@ static ssize_t dapm_widget_show(struct d struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); int i, count = 0; + mutex_lock(&rtd->card->dapm_mutex); + for (i = 0; i < rtd->num_codecs; i++) { struct snd_soc_codec *codec = rtd->codec_dais[i]->codec; count += dapm_widget_show_codec(codec, buf + count); } + mutex_unlock(&rtd->card->dapm_mutex); + return count; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/