From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751124AbbIXS4M (ORCPT ); Thu, 24 Sep 2015 14:56:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:41395 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750710AbbIXS4L (ORCPT ); Thu, 24 Sep 2015 14:56:11 -0400 Date: Thu, 24 Sep 2015 20:56:08 +0200 Message-ID: From: Takashi Iwai To: "Luis de Bethencourt" Cc: , , , , , Subject: Re: [PATCH v2] sound: oss: ad1848: Fix returned errno code in ad1848_init() In-Reply-To: <1443117510-26906-1-git-send-email-luisbg@osg.samsung.com> References: <1443117510-26906-1-git-send-email-luisbg@osg.samsung.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.5 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Sep 2015 19:58:30 +0200, Luis de Bethencourt wrote: > > 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. Where is the propagated error number referred? In other words, do we have a clear merit of changing this old stuff with rather a risk of regression? thanks, Takashi > 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; > -- > 2.5.1 > >