From patchwork Thu Sep 24 17:58:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis de Bethencourt X-Patchwork-Id: 7259801 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 41FE1BEEC1 for ; Thu, 24 Sep 2015 17:59:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A54120800 for ; Thu, 24 Sep 2015 17:58:59 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2E5E32092B for ; Thu, 24 Sep 2015 17:58:58 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 75147265D44; Thu, 24 Sep 2015 19:58:56 +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=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 3289A26058F; Thu, 24 Sep 2015 19:58:48 +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 A47D8260592; Thu, 24 Sep 2015 19:58:45 +0200 (CEST) Received: from lists.s-osg.org (lists.s-osg.org [54.187.51.154]) by alsa0.perex.cz (Postfix) with ESMTP id 6E56C26058D for ; Thu, 24 Sep 2015 19:58:38 +0200 (CEST) Received: from snow.seri.co.uk (cpc9-slam5-2-0-cust824.2-4.cable.virginm.net [81.108.163.57]) by lists.s-osg.org (Postfix) with ESMTPSA id 725B14632B; Thu, 24 Sep 2015 10:58:35 -0700 (PDT) From: Luis de Bethencourt To: linux-kernel@vger.kernel.org Date: Thu, 24 Sep 2015 18:58:30 +0100 Message-Id: <1443117510-26906-1-git-send-email-luisbg@osg.samsung.com> X-Mailer: git-send-email 2.5.1 Cc: alsa-devel@alsa-project.org, tiwai@suse.com, elfring@users.sourceforge.net, Luis de Bethencourt , joe@perches.com, sudipm.mukherjee@gmail.com Subject: [alsa-devel] [PATCH v2] sound: oss: ad1848: Fix returned errno code in ad1848_init() 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 The driver is using -1 instead of the -ENOMEM defined macro to specify that a buffer allocation failed. Since the error number is propagated, the caller will get a -EPERM which is the wrong error condition. Changed the checks of the return of ad1848_init() to be for >= 0, instead of != -1. Smatch tool warning: ad1848_init() warn: returning -1 instead of -ENOMEM is sloppy Signed-off-by: Luis de Bethencourt --- sound/oss/ad1848.c | 4 ++-- sound/oss/dev_table.c | 2 +- sound/oss/pss.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 10c8de1..58c6d31 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c @@ -1992,7 +1992,7 @@ int ad1848_init (char *name, struct resource *ports, int irq, int dma_playback, portc = kmalloc(sizeof(ad1848_port_info), GFP_KERNEL); if(portc==NULL) { release_region(devc->base, 4); - return -1; + return -ENOMEM; } if ((my_dev = sound_install_audiodrv(AUDIO_DRIVER_VERSION, @@ -2007,7 +2007,7 @@ int ad1848_init (char *name, struct resource *ports, int irq, int dma_playback, { release_region(devc->base, 4); kfree(portc); - return -1; + return my_dev; } audio_devs[my_dev]->portc = portc; diff --git a/sound/oss/dev_table.c b/sound/oss/dev_table.c index 6dad515..abb3db4 100644 --- a/sound/oss/dev_table.c +++ b/sound/oss/dev_table.c @@ -148,7 +148,7 @@ EXPORT_SYMBOL(sound_install_mixer); void sound_unload_audiodev(int dev) { - if (dev != -1) { + if (dev >= 0) { DMAbuf_deinit(dev); audio_devs[dev] = NULL; unregister_sound_dsp((dev<<4)+3); diff --git a/sound/oss/pss.c b/sound/oss/pss.c index 81314f9..e84aafe 100644 --- a/sound/oss/pss.c +++ b/sound/oss/pss.c @@ -1091,7 +1091,7 @@ static int __init probe_pss_mss(struct address_info *hw_config) pss_mixer_reset(devc); attach_ms_sound(hw_config, ports, THIS_MODULE); /* Slot 0 */ - if (hw_config->slots[0] != -1) + if (hw_config->slots[0] >= 0) { /* The MSS driver installed itself */ audio_devs[hw_config->slots[0]]->coproc = &pss_coproc_operations;