]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ALSA: usb: caiaq: check for cdev->n_streams > 1
authorDaniel Mack <daniel@zonque.org>
Tue, 7 Oct 2014 12:25:13 +0000 (14:25 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 7 Oct 2014 12:34:25 +0000 (14:34 +0200)
Coverity spotted a possible DIV0 condition when cdev->n_streams is 0.

Fix this by making sure the value is > 1 in snd_usb_caiaq_audio_init().

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/caiaq/audio.c

index 7103b0908d130436743bceb6bf422222bd421466..272844746135763faa6425aae3fb8dc3bfc9ec50 100644 (file)
@@ -816,6 +816,11 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
                return -EINVAL;
        }
 
+       if (cdev->n_streams < 2) {
+               dev_err(dev, "bogus number of streams: %d\n", cdev->n_streams);
+               return -EINVAL;
+       }
+
        ret = snd_pcm_new(cdev->chip.card, cdev->product_name, 0,
                        cdev->n_audio_out, cdev->n_audio_in, &cdev->pcm);