* Re: ASoC: Add max98925 codec driver
@ 2015-03-17 18:28 Dan Carpenter
2015-07-20 11:07 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-03-17 18:28 UTC (permalink / raw)
To: yesanishhere; +Cc: alsa-devel
Hello Anish Kumar,
The patch 1ff2765182d1: "ASoC: Add max98925 codec driver" from Mar 9,
2015, leads to the following static checker warning:
sound/soc/codecs/max98925.c:274 max98925_rate_value()
error: buffer overflow 'rate_table' 9 <= 9
sound/soc/codecs/max98925.c
259 static inline int max98925_rate_value(struct snd_soc_codec *codec,
260 int rate, int clock, int *value, int *n, int *m)
261 {
262 int ret = -EINVAL;
263 int i;
264
265 for (i = 0; i < ARRAY_SIZE(rate_table); i++) {
266 if (rate_table[i].rate >= rate) {
267 *value = rate_table[i].sr;
268 *n = rate_table[i].divisors[clock][0];
269 *m = rate_table[i].divisors[clock][1];
270 ret = 0;
271 break;
272 }
273 }
274 dev_dbg(codec->dev, "%s: sample rate is %d, returning %d\n",
275 __func__, rate_table[i].rate, *value);
^^^^^^^^^^^^^^^^^^
If we don't break then we're off by one.
276 return ret;
277 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ASoC: Add max98925 codec driver
2015-03-17 18:28 ASoC: Add max98925 codec driver Dan Carpenter
@ 2015-07-20 11:07 ` Dan Carpenter
2015-07-20 15:59 ` anish kumar
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-07-20 11:07 UTC (permalink / raw)
To: yesanishhere; +Cc: alsa-devel
On Tue, Mar 17, 2015 at 09:28:43PM +0300, Dan Carpenter wrote:
> Hello Anish Kumar,
>
> The patch 1ff2765182d1: "ASoC: Add max98925 codec driver" from Mar 9,
> 2015, leads to the following static checker warning:
>
> sound/soc/codecs/max98925.c:274 max98925_rate_value()
> error: buffer overflow 'rate_table' 9 <= 9
>
> sound/soc/codecs/max98925.c
> 259 static inline int max98925_rate_value(struct snd_soc_codec *codec,
> 260 int rate, int clock, int *value, int *n, int *m)
> 261 {
> 262 int ret = -EINVAL;
> 263 int i;
> 264
> 265 for (i = 0; i < ARRAY_SIZE(rate_table); i++) {
> 266 if (rate_table[i].rate >= rate) {
> 267 *value = rate_table[i].sr;
> 268 *n = rate_table[i].divisors[clock][0];
> 269 *m = rate_table[i].divisors[clock][1];
> 270 ret = 0;
> 271 break;
> 272 }
> 273 }
> 274 dev_dbg(codec->dev, "%s: sample rate is %d, returning %d\n",
> 275 __func__, rate_table[i].rate, *value);
> ^^^^^^^^^^^^^^^^^^
> If we don't break then we're off by one.
I'm going to just delete this because these warnings are annoying and
debug printks are pointless and if you cared then you would have fixed
it by now.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ASoC: Add max98925 codec driver
2015-07-20 11:07 ` Dan Carpenter
@ 2015-07-20 15:59 ` anish kumar
0 siblings, 0 replies; 3+ messages in thread
From: anish kumar @ 2015-07-20 15:59 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Linux-ALSA
On Mon, Jul 20, 2015 at 4:07 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Tue, Mar 17, 2015 at 09:28:43PM +0300, Dan Carpenter wrote:
>> Hello Anish Kumar,
>>
>> The patch 1ff2765182d1: "ASoC: Add max98925 codec driver" from Mar 9,
>> 2015, leads to the following static checker warning:
>>
>> sound/soc/codecs/max98925.c:274 max98925_rate_value()
>> error: buffer overflow 'rate_table' 9 <= 9
>>
>> sound/soc/codecs/max98925.c
>> 259 static inline int max98925_rate_value(struct snd_soc_codec *codec,
>> 260 int rate, int clock, int *value, int *n, int *m)
>> 261 {
>> 262 int ret = -EINVAL;
>> 263 int i;
>> 264
>> 265 for (i = 0; i < ARRAY_SIZE(rate_table); i++) {
>> 266 if (rate_table[i].rate >= rate) {
>> 267 *value = rate_table[i].sr;
>> 268 *n = rate_table[i].divisors[clock][0];
>> 269 *m = rate_table[i].divisors[clock][1];
>> 270 ret = 0;
>> 271 break;
>> 272 }
>> 273 }
>> 274 dev_dbg(codec->dev, "%s: sample rate is %d, returning %d\n",
>> 275 __func__, rate_table[i].rate, *value);
>> ^^^^^^^^^^^^^^^^^^
>> If we don't break then we're off by one.
>
> I'm going to just delete this because these warnings are annoying and
> debug printks are pointless and if you cared then you would have fixed
> it by now.
Please go ahead.
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-20 15:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-17 18:28 ASoC: Add max98925 codec driver Dan Carpenter
2015-07-20 11:07 ` Dan Carpenter
2015-07-20 15:59 ` anish kumar
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.