mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
ALSA: hda/ca0132 - Avoid division by zero in dspxfr_one_seg()
Move the zero check `hda_frame_size_words == 0' before the modulus `buffer_size_words % hda_frame_size_words'. Also remove the redundant null check `buffer_addx == NULL'. Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
4c7a548a70
commit
3bc085a12d
@ -2298,6 +2298,11 @@ static int dspxfr_one_seg(struct hda_codec *codec,
|
|||||||
hda_frame_size_words = ((sample_rate_div == 0) ? 0 :
|
hda_frame_size_words = ((sample_rate_div == 0) ? 0 :
|
||||||
(num_chans * sample_rate_mul / sample_rate_div));
|
(num_chans * sample_rate_mul / sample_rate_div));
|
||||||
|
|
||||||
|
if (hda_frame_size_words == 0) {
|
||||||
|
snd_printdd(KERN_ERR "frmsz zero\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
buffer_size_words = min(buffer_size_words,
|
buffer_size_words = min(buffer_size_words,
|
||||||
(unsigned int)(UC_RANGE(chip_addx, 1) ?
|
(unsigned int)(UC_RANGE(chip_addx, 1) ?
|
||||||
65536 : 32768));
|
65536 : 32768));
|
||||||
@ -2308,8 +2313,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
|
|||||||
chip_addx, hda_frame_size_words, num_chans,
|
chip_addx, hda_frame_size_words, num_chans,
|
||||||
sample_rate_mul, sample_rate_div, buffer_size_words);
|
sample_rate_mul, sample_rate_div, buffer_size_words);
|
||||||
|
|
||||||
if ((buffer_addx == NULL) || (hda_frame_size_words == 0) ||
|
if (buffer_size_words < hda_frame_size_words) {
|
||||||
(buffer_size_words < hda_frame_size_words)) {
|
|
||||||
snd_printdd(KERN_ERR "dspxfr_one_seg:failed\n");
|
snd_printdd(KERN_ERR "dspxfr_one_seg:failed\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user