summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorXi Wang <xi.wang@gmail.com>2013-03-07 00:13:51 -0500
committerTakashi Iwai <tiwai@suse.de>2013-03-07 09:18:00 +0100
commit3bc085a12d8f9f3e45a4ac0cc24a34abd5b20657 (patch)
treee4957c34b8cd36f94326724fa777e6b633f5e832 /sound
parent4c7a548a70a44269266858f65c3b5fc9c3ace057 (diff)
downloadop-kernel-dev-3bc085a12d8f9f3e45a4ac0cc24a34abd5b20657.zip
op-kernel-dev-3bc085a12d8f9f3e45a4ac0cc24a34abd5b20657.tar.gz
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>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/patch_ca0132.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index db02c1e..eefc456 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -2298,6 +2298,11 @@ static int dspxfr_one_seg(struct hda_codec *codec,
hda_frame_size_words = ((sample_rate_div == 0) ? 0 :
(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,
(unsigned int)(UC_RANGE(chip_addx, 1) ?
65536 : 32768));
@@ -2308,8 +2313,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
chip_addx, hda_frame_size_words, num_chans,
sample_rate_mul, sample_rate_div, buffer_size_words);
- if ((buffer_addx == NULL) || (hda_frame_size_words == 0) ||
- (buffer_size_words < hda_frame_size_words)) {
+ if (buffer_size_words < hda_frame_size_words) {
snd_printdd(KERN_ERR "dspxfr_one_seg:failed\n");
return -EINVAL;
}
OpenPOWER on IntegriCloud