Skip to content

Commit

Permalink
ALSA: usb: caiaq: check for cdev->n_streams > 1
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
zonque authored and tiwai committed Oct 7, 2014
1 parent 9d36a7d commit 897c329
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sound/usb/caiaq/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 897c329

Please sign in to comment.