From patchwork Fri May 18 09:16:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10408973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5189A60230 for ; Fri, 18 May 2018 09:16:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DAFD288CA for ; Fri, 18 May 2018 09:16:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31FFE288E2; Fri, 18 May 2018 09:16:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4668D288CA for ; Fri, 18 May 2018 09:16:29 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id A3CF526707F; Fri, 18 May 2018 11:16:25 +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 0C47A267669; Fri, 18 May 2018 11:16:24 +0200 (CEST) Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by alsa0.perex.cz (Postfix) with ESMTP id CD237266F44 for ; Fri, 18 May 2018 11:16:21 +0200 (CEST) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4I9GIkG021311; Fri, 18 May 2018 09:16:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=7TjWhyjFI7F1C2c6Ja+hA9dGRbdqs/8PyEuMb1WIfz0=; b=d4dZQrqtzB5+iCQ9CgYtdMz9IArN3Im/dfH6QMOaNVRo1jhukOIWnt3OZGvEOSMuehAA kJzfJteXRKn/ERVwbkjAT0f2Pqs7IWDr/z7243psOwPjD6tvEWiN+wHH9LpnZNhU7UIL itxrt3NP/qT9US9HhqWEMAb0mKUzxUe10laFNr++FVwmCjaMXyV6scwZAHM4iLMxk/v8 YYEu9/9Mg+FFvIHfIh37quIEIhTE17lk4pI4ykVn6HLaEZa+Wp8N5O5rKMiupITsD/N0 jaDnxkx0ZoA5eSBAbPqOaZV5iOLhcgfLBEIfF+5cNXM06rsmIlL+ATWyylW1j+lYyuM1 PA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2hx29wcje6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 May 2018 09:16:18 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4I9GHri024290 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 May 2018 09:16:17 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4I9GFKK030770; Fri, 18 May 2018 09:16:16 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 May 2018 02:16:15 -0700 Date: Fri, 18 May 2018 12:16:07 +0300 From: Dan Carpenter To: Clemens Ladisch , Takashi Sakamoto Message-ID: <20180518091607.GA32078@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8896 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805180102 Cc: alsa-devel@alsa-project.org, Takashi Sakamoto , kernel-janitors@vger.kernel.org, Takashi Iwai Subject: [alsa-devel] [PATCH] ALSA: dice: fix a bounds check in snd_dice_detect_tcelectronic_formats() 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The "entry" pointer is always non-NULL so this test for out of bounds won't work. Fixes: f1f0f330b1d0 ("ALSA: dice: add parameters of stream formats for models produced by TC Electronic") Signed-off-by: Dan Carpenter Reviewed-by: Takashi Sakamoto diff --git a/sound/firewire/dice/dice-tcelectronic.c b/sound/firewire/dice/dice-tcelectronic.c index af8203b9d1a6..e134a5110c6c 100644 --- a/sound/firewire/dice/dice-tcelectronic.c +++ b/sound/firewire/dice/dice-tcelectronic.c @@ -75,13 +75,12 @@ int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice) } } - entry = NULL; for (i = 0; i < ARRAY_SIZE(entries); ++i) { entry = entries + i; if (entry->model_id == model_id) break; } - if (!entry) + if (i == ARRAY_SIZE(entries)) return -ENODEV; memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,