Commit 315e8f7501ad929acacfa94c251283e837f281ed
Committed by
Takashi Iwai
1 parent
1d8c1100fb
Exists in
master
and in
7 other branches
ALSA: asihpi: fix sign bug
bytes_per_sec is unsigned, so if snd_pcm_format_width() return error we would not see it. Signed-off-by: Kulikov Vasiliy <segooon@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff
sound/pci/asihpi/asihpi.c
... | ... | @@ -460,6 +460,7 @@ |
460 | 460 | struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); |
461 | 461 | int err; |
462 | 462 | u16 format; |
463 | + int width; | |
463 | 464 | unsigned int bytes_per_sec; |
464 | 465 | |
465 | 466 | print_hwparams(params); |
466 | 467 | |
... | ... | @@ -512,9 +513,10 @@ |
512 | 513 | dpcm->hpi_buffer_attached); |
513 | 514 | } |
514 | 515 | bytes_per_sec = params_rate(params) * params_channels(params); |
515 | - bytes_per_sec *= snd_pcm_format_width(params_format(params)); | |
516 | + width = snd_pcm_format_width(params_format(params)); | |
517 | + bytes_per_sec *= width; | |
516 | 518 | bytes_per_sec /= 8; |
517 | - if (bytes_per_sec <= 0) | |
519 | + if (width < 0 || bytes_per_sec == 0) | |
518 | 520 | return -EINVAL; |
519 | 521 | |
520 | 522 | dpcm->bytes_per_sec = bytes_per_sec; |