* [PATCH] ASoC: davinci-mcasp: Fix ruledata setup in davinci_mcasp_startup
@ 2015-04-07 11:03 Peter Ujfalusi
2015-04-07 11:05 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Peter Ujfalusi @ 2015-04-07 11:03 UTC (permalink / raw)
To: broonie, liam.r.girdwood, jsarha; +Cc: alsa-devel
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 <peter.ujfalusi@ti.com>
---
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)
--
2.3.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: davinci-mcasp: Fix ruledata setup in davinci_mcasp_startup
2015-04-07 11:03 [PATCH] ASoC: davinci-mcasp: Fix ruledata setup in davinci_mcasp_startup Peter Ujfalusi
@ 2015-04-07 11:05 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2015-04-07 11:05 UTC (permalink / raw)
To: Peter Ujfalusi; +Cc: liam.r.girdwood, alsa-devel, jsarha
[-- Attachment #1.1: Type: text/plain, Size: 408 bytes --]
On Tue, Apr 07, 2015 at 02:03:53PM +0300, Peter Ujfalusi wrote:
> 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.
Applied, thanks.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-07 11:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 11:03 [PATCH] ASoC: davinci-mcasp: Fix ruledata setup in davinci_mcasp_startup Peter Ujfalusi
2015-04-07 11:05 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).