diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2015-04-07 07:03:53 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-04-07 07:05:44 -0400 |
commit | 4cd9db08598454e4d051b818c5f1d61ac7539a47 (patch) | |
tree | bda0bbad6d76044e76e8a714046bf998022a4168 /sound/soc/davinci | |
parent | 7b3d165a282145e605247148d3dec034814e0a78 (diff) |
ASoC: davinci-mcasp: Fix ruledata setup in davinci_mcasp_startup
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>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/davinci')
-rw-r--r-- | sound/soc/davinci/davinci-mcasp.c | 12 |
1 files 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, | |||
1128 | struct snd_soc_dai *cpu_dai) | 1128 | struct snd_soc_dai *cpu_dai) |
1129 | { | 1129 | { |
1130 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); | 1130 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); |
1131 | struct davinci_mcasp_ruledata *ruledata = | ||
1132 | &mcasp->ruledata[substream->stream]; | ||
1131 | u32 max_channels = 0; | 1133 | u32 max_channels = 0; |
1132 | int i, dir; | 1134 | int i, dir; |
1133 | 1135 | ||
@@ -1149,7 +1151,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, | |||
1149 | if (mcasp->serial_dir[i] == dir) | 1151 | if (mcasp->serial_dir[i] == dir) |
1150 | max_channels++; | 1152 | max_channels++; |
1151 | } | 1153 | } |
1152 | mcasp->ruledata[substream->stream].serializers = max_channels; | 1154 | ruledata->serializers = max_channels; |
1153 | max_channels *= mcasp->tdm_slots; | 1155 | max_channels *= mcasp->tdm_slots; |
1154 | /* | 1156 | /* |
1155 | * If the already active stream has less channels than the calculated | 1157 | * 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, | |||
1172 | if (mcasp->bclk_master && mcasp->bclk_div == 0 && mcasp->sysclk_freq) { | 1174 | if (mcasp->bclk_master && mcasp->bclk_div == 0 && mcasp->sysclk_freq) { |
1173 | int ret; | 1175 | int ret; |
1174 | 1176 | ||
1175 | mcasp->ruledata[substream->stream].mcasp = mcasp; | 1177 | ruledata->mcasp = mcasp; |
1176 | 1178 | ||
1177 | ret = snd_pcm_hw_rule_add(substream->runtime, 0, | 1179 | ret = snd_pcm_hw_rule_add(substream->runtime, 0, |
1178 | SNDRV_PCM_HW_PARAM_RATE, | 1180 | SNDRV_PCM_HW_PARAM_RATE, |
1179 | davinci_mcasp_hw_rule_rate, | 1181 | davinci_mcasp_hw_rule_rate, |
1180 | &mcasp->ruledata[dir], | 1182 | ruledata, |
1181 | SNDRV_PCM_HW_PARAM_FORMAT, | 1183 | SNDRV_PCM_HW_PARAM_FORMAT, |
1182 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); | 1184 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); |
1183 | if (ret) | 1185 | if (ret) |
@@ -1185,7 +1187,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, | |||
1185 | ret = snd_pcm_hw_rule_add(substream->runtime, 0, | 1187 | ret = snd_pcm_hw_rule_add(substream->runtime, 0, |
1186 | SNDRV_PCM_HW_PARAM_FORMAT, | 1188 | SNDRV_PCM_HW_PARAM_FORMAT, |
1187 | davinci_mcasp_hw_rule_format, | 1189 | davinci_mcasp_hw_rule_format, |
1188 | &mcasp->ruledata[dir], | 1190 | ruledata, |
1189 | SNDRV_PCM_HW_PARAM_RATE, | 1191 | SNDRV_PCM_HW_PARAM_RATE, |
1190 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); | 1192 | SNDRV_PCM_HW_PARAM_CHANNELS, -1); |
1191 | if (ret) | 1193 | if (ret) |
@@ -1193,7 +1195,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream, | |||
1193 | ret = snd_pcm_hw_rule_add(substream->runtime, 0, | 1195 | ret = snd_pcm_hw_rule_add(substream->runtime, 0, |
1194 | SNDRV_PCM_HW_PARAM_CHANNELS, | 1196 | SNDRV_PCM_HW_PARAM_CHANNELS, |
1195 | davinci_mcasp_hw_rule_channels, | 1197 | davinci_mcasp_hw_rule_channels, |
1196 | &mcasp->ruledata[dir], | 1198 | ruledata, |
1197 | SNDRV_PCM_HW_PARAM_RATE, | 1199 | SNDRV_PCM_HW_PARAM_RATE, |
1198 | SNDRV_PCM_HW_PARAM_FORMAT, -1); | 1200 | SNDRV_PCM_HW_PARAM_FORMAT, -1); |
1199 | if (ret) | 1201 | if (ret) |