From patchwork Sun Feb 1 20:49:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 5757721 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 60E24BF440 for ; Sun, 1 Feb 2015 20:49:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61D5820218 for ; Sun, 1 Feb 2015 20:49:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 888EA201E4 for ; Sun, 1 Feb 2015 20:49:52 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id CF397260462; Sun, 1 Feb 2015 21:49:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SUBJ_OBFU_PUNCT_MANY, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id EE451260438; Sun, 1 Feb 2015 21:49:37 +0100 (CET) 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 50C46260440; Sun, 1 Feb 2015 21:49:36 +0100 (CET) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by alsa0.perex.cz (Postfix) with ESMTP id CE63C260437 for ; Sun, 1 Feb 2015 21:49:28 +0100 (CET) Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t11KnPXj027035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 1 Feb 2015 20:49:26 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t11KnM13024838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 1 Feb 2015 20:49:22 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t11KnLfO024831; Sun, 1 Feb 2015 20:49:21 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 01 Feb 2015 12:49:21 -0800 Date: Sun, 1 Feb 2015 23:49:02 +0300 From: Dan Carpenter To: Jaroslav Kysela Message-ID: <20150201204902.GA29129@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen , Benoit Taine , Takashi Iwai , kernel-janitors@vger.kernel.org, Hans Wennborg , Bjorn Helgaas Subject: [alsa-devel] [patch] ALSA: riptide: off by one in snd_riptide_joystick_probe() 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 There is an off by one bug in snd_riptide_joystick_probe() because we do the "dev++" toward the start of the function instead of waiting until the end. The impact of this bug is: 1) A static checker warning. 2) If you connect 32 joysticks to your computer they will fail to load with a different error message than intended. 3) If you pass a module option to specify a non-default joystick port then the parameter array has to be shifted one element. The first two are not serious. For the third one, it's probably too late to change it since the bug was introduced in 2009. Either no one noticed and we can leave it alone, or if they did notice, they probably have implemented work arounds so we can't change it now without confusing them. So instead of fixing it the "theoretically correct way", I have decided to just work around it by making the joystick_port[] one element larger. This silences the static checker warning and doesn't affect user space. Fixes: db1005ec6ff8 ('ALSA: riptide - Fix joystick resource handling') Signed-off-by: Dan Carpenter diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 29f2827..324e34c 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -125,7 +125,11 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; #ifdef SUPPORT_JOYSTICK -static int joystick_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x200 }; +/* + * The joystick_port accounting is off by one but I'm afraid to change it for + * fear of breaking userspace. + */ +static int joystick_port[SNDRV_CARDS + 1] = { [0 ... (SNDRV_CARDS)] = 0x200 }; #endif static int mpu_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x330 }; static int opl3_port[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS - 1)] = 0x388 };