From patchwork Tue Apr 7 11:03:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 6168891 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DB117BF4A6 for ; Tue, 7 Apr 2015 11:04:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 023E320263 for ; Tue, 7 Apr 2015 11:04:19 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C339820259 for ; Tue, 7 Apr 2015 11:04:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 638A32617E0; Tue, 7 Apr 2015 13:04:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 3C42626050C; Tue, 7 Apr 2015 13:04:07 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id CA5E1260545; Tue, 7 Apr 2015 13:04:06 +0200 (CEST) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by alsa0.perex.cz (Postfix) with ESMTP id 443D42604BD for ; Tue, 7 Apr 2015 13:03:58 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id t37B3weL013411; Tue, 7 Apr 2015 06:03:58 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t37B3u2N005750; Tue, 7 Apr 2015 06:03:56 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Tue, 7 Apr 2015 06:03:56 -0500 Received: from dflp32.itg.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t37B3sbP023122; Tue, 7 Apr 2015 06:03:55 -0500 From: Peter Ujfalusi To: , , Date: Tue, 7 Apr 2015 14:03:53 +0300 Message-ID: <1428404633-25365-1-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.3.5 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] ASoC: davinci-mcasp: Fix ruledata setup in davinci_mcasp_startup X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Passing &mcasp->ruledata[dir] to snd_pcm_hw_rule_add() is not correct since commit: 7b3d165a2821 ASoC: davinci-mcasp: Index ruledata in drvdata with substream->stream now sets up the struct based on the substream->stream (0 or 1) while we pass a pointer which we take with dir (1 or 2). This will lead kernel crash. Signed-off-by: Peter Ujfalusi --- sound/soc/davinci/davinci-mcasp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 0b6b1b286201..bb4b78eada58 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1128,6 +1128,8 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); + struct davinci_mcasp_ruledata *ruledata = + &mcasp->ruledata[substream->stream]; u32 max_channels = 0; int i, dir; @@ -1149,7 +1151,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, if (mcasp->serial_dir[i] == dir) max_channels++; } - mcasp->ruledata[substream->stream].serializers = max_channels; + ruledata->serializers = max_channels; max_channels *= mcasp->tdm_slots; /* * If the already active stream has less channels than the calculated @@ -1172,12 +1174,12 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, if (mcasp->bclk_master && mcasp->bclk_div == 0 && mcasp->sysclk_freq) { int ret; - mcasp->ruledata[substream->stream].mcasp = mcasp; + ruledata->mcasp = mcasp; ret = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, davinci_mcasp_hw_rule_rate, - &mcasp->ruledata[dir], + ruledata, SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_CHANNELS, -1); if (ret) @@ -1185,7 +1187,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, ret = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, davinci_mcasp_hw_rule_format, - &mcasp->ruledata[dir], + ruledata, SNDRV_PCM_HW_PARAM_RATE, SNDRV_PCM_HW_PARAM_CHANNELS, -1); if (ret) @@ -1193,7 +1195,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, ret = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, davinci_mcasp_hw_rule_channels, - &mcasp->ruledata[dir], + ruledata, SNDRV_PCM_HW_PARAM_RATE, SNDRV_PCM_HW_PARAM_FORMAT, -1); if (ret)