All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used
@ 2015-03-27  6:20 Dan Carpenter
  2015-03-27  9:47 ` [PATCH] ASoC: davinci-mcasp: Index ruledata in drvdata with substream->stream Jyri Sarha
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-03-27  6:20 UTC (permalink / raw)
  To: jsarha; +Cc: alsa-devel

Hello Jyri Sarha,

The patch a75a053f1eef: "ASoC: davinci-mcasp: Set rule constraints if
implicit BCLK divider is used" from Mar 20, 2015, leads to the
following Smatch warning:

	sound/soc/davinci/davinci-mcasp.c:1152 davinci_mcasp_startup()
	error: buffer overflow 'mcasp->ruledata' 2 <= 2

sound/soc/davinci/davinci-mcasp.c
  1138  
  1139          /*
  1140           * Limit the maximum allowed channels for the first stream:
  1141           * number of serializers for the direction * tdm slots per serializer
  1142           */
  1143          if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  1144                  dir = TX_MODE;
  1145          else
  1146                  dir = RX_MODE;

dir is either 1 or 2.

  1147  
  1148          for (i = 0; i < mcasp->num_serializer; i++) {
  1149                  if (mcasp->serial_dir[i] == dir)
  1150                          max_channels++;
  1151          }
  1152          mcasp->ruledata[dir].serializers = max_channels;
                       ^^^^^^^^^^^^^
->ruledata[] has only two elements so ->ruledata[2] is beyond the end of
the array.

  1153          max_channels *= mcasp->tdm_slots;

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] ASoC: davinci-mcasp: Index ruledata in drvdata with substream->stream
  2015-03-27  6:20 ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used Dan Carpenter
@ 2015-03-27  9:47 ` Jyri Sarha
  2015-04-01 20:34   ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Jyri Sarha @ 2015-03-27  9:47 UTC (permalink / raw)
  To: alsa-devel, linux-omap
  Cc: peter.ujfalusi, broonie, liam.r.girdwood, dan.carpenter, Jyri Sarha

The serializer direction definitions runs from 1 to 2, which does not
suite the purpose. The substream->stream is perfect for the purpose
and should have been used from the beginning.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 sound/soc/davinci/davinci-mcasp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 76156d18..0b6b1b2 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -1149,7 +1149,7 @@ static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
 		if (mcasp->serial_dir[i] == dir)
 			max_channels++;
 	}
-	mcasp->ruledata[dir].serializers = max_channels;
+	mcasp->ruledata[substream->stream].serializers = max_channels;
 	max_channels *= mcasp->tdm_slots;
 	/*
 	 * If the already active stream has less channels than the calculated
@@ -1172,7 +1172,7 @@ 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[dir].mcasp = mcasp;
+		mcasp->ruledata[substream->stream].mcasp = mcasp;
 
 		ret = snd_pcm_hw_rule_add(substream->runtime, 0,
 					  SNDRV_PCM_HW_PARAM_RATE,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: davinci-mcasp: Index ruledata in drvdata with substream->stream
  2015-03-27  9:47 ` [PATCH] ASoC: davinci-mcasp: Index ruledata in drvdata with substream->stream Jyri Sarha
@ 2015-04-01 20:34   ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2015-04-01 20:34 UTC (permalink / raw)
  To: Jyri Sarha
  Cc: alsa-devel, linux-omap, peter.ujfalusi, liam.r.girdwood, dan.carpenter

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

On Fri, Mar 27, 2015 at 11:47:51AM +0200, Jyri Sarha wrote:
> The serializer direction definitions runs from 1 to 2, which does not
> suite the purpose. The substream->stream is perfect for the purpose
> and should have been used from the beginning.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-01 20:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27  6:20 ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used Dan Carpenter
2015-03-27  9:47 ` [PATCH] ASoC: davinci-mcasp: Index ruledata in drvdata with substream->stream Jyri Sarha
2015-04-01 20:34   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.