From patchwork Tue Oct 7 12:25:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 5045691 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E054A9F295 for ; Tue, 7 Oct 2014 12:25:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A29F201FB for ; Tue, 7 Oct 2014 12:25:45 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9230C20211 for ; Tue, 7 Oct 2014 12:25:42 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 50FF126048C; Tue, 7 Oct 2014 14:25:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 1A339260473; Tue, 7 Oct 2014 14:25:28 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A9D2426047E; Tue, 7 Oct 2014 14:25:26 +0200 (CEST) Received: from mail.zonque.de (svenfoo.org [82.94.215.22]) by alsa0.perex.cz (Postfix) with ESMTP id AFDD2260452 for ; Tue, 7 Oct 2014 14:25:18 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.zonque.de (Postfix) with ESMTP id 46A50C5226; Tue, 7 Oct 2014 14:25:17 +0200 (CEST) Received: from mail.zonque.de ([127.0.0.1]) by localhost (rambrand.bugwerft.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4chGZpah5Evx; Tue, 7 Oct 2014 14:25:17 +0200 (CEST) Received: from tamtam.fritz.box (p54AF41BA.dip0.t-ipconnect.de [84.175.65.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.zonque.de (Postfix) with ESMTPSA id C4DAEC0A8F; Tue, 7 Oct 2014 14:25:16 +0200 (CEST) From: Daniel Mack To: alsa-devel@alsa-project.org Date: Tue, 7 Oct 2014 14:25:13 +0200 Message-Id: <1412684713-6622-1-git-send-email-daniel@zonque.org> X-Mailer: git-send-email 2.1.0 Cc: tiwai@suse.de, Daniel Mack Subject: [alsa-devel] [PATCH] ALSA: usb: caiaq: check for cdev->n_streams > 1 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- sound/usb/caiaq/audio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 7103b09..2728447 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -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);