All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used
@ 2015-04-10  9:33 Dan Carpenter
  2015-04-13 11:39 ` Jyri Sarha
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2015-04-10  9:33 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 Sparse warning:

	sound/soc/davinci/davinci-mcasp.c:1098:45:
	warning: Variable length array is used.

sound/soc/davinci/davinci-mcasp.c
  1088  static int davinci_mcasp_hw_rule_channels(struct snd_pcm_hw_params *params,
  1089                                            struct snd_pcm_hw_rule *rule)
  1090  {
  1091          struct davinci_mcasp_ruledata *rd = rule->private;
  1092          struct snd_interval *ci =
  1093                  hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1094          int sbits = params_width(params);
  1095          int rate = params_rate(params);
  1096          int max_chan_per_wire = rd->mcasp->tdm_slots < ci->max ?
  1097                  rd->mcasp->tdm_slots : ci->max;
  1098          unsigned int list[ci->max - ci->min + 1];
                                  ^^^^^^^^^^^^^^^^^^^^^
I wasnt able to determine where these values are capped.  The worry is
that the kernel only has an 8k stack so if they are too high it could
oops.  I think these values can come from the user in
snd_pcm_hw_params_user() but I'm an newbie to the code and I didn't
see where the limits were enforced.

  1099          int c1, c, count = 0;
  1100  
  1101          for (c1 = ci->min; c1 <= max_chan_per_wire; c1++) {
  1102                  uint bclk_freq = c1*sbits*rate;
  1103                  int ppm;


regards,
dan carpenter

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used
@ 2015-03-27  6:20 Dan Carpenter
  0 siblings, 0 replies; 7+ 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] 7+ messages in thread

end of thread, other threads:[~2015-04-13 14:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-10  9:33 ASoC: davinci-mcasp: Set rule constraints if implicit BCLK divider is used Dan Carpenter
2015-04-13 11:39 ` Jyri Sarha
2015-04-13 12:16   ` Dan Carpenter
2015-04-13 13:32     ` Jyri Sarha
2015-04-13 13:58       ` Dan Carpenter
2015-04-13 14:22         ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2015-03-27  6:20 Dan Carpenter

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.