All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Luis de Bethencourt <luisbg@osg.samsung.com>
Cc: alsa-devel@alsa-project.org, tiwai@suse.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sound: oss: ad1848: Fix returned errno code in ad1848_init()
Date: Tue, 22 Sep 2015 22:16:42 +0530	[thread overview]
Message-ID: <20150922164642.GA14353@sudip-pc> (raw)
In-Reply-To: <1442936257-8988-1-git-send-email-luisbg@osg.samsung.com>

On Tue, Sep 22, 2015 at 04:37:37PM +0100, 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.
> 
> Smatch tool warning:
> ad1848_init() warn: returning -1 instead of -ENOMEM is sloppy
> 
> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
> ---
>  sound/oss/ad1848.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
> index 10c8de1..6b35656 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;
 The return value of ad1848_init is stored in hw_config->slots[0].
And in sound/oss/pss.c hw_config->slots[0] is checked like: 
if (hw_config->slots[0] != -1)

So, you just changed the functionality of the driver.

regards
sudip

WARNING: multiple messages have this Message-ID (diff)
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Luis de Bethencourt <luisbg@osg.samsung.com>
Cc: linux-kernel@vger.kernel.org, perex@perex.cz, tiwai@suse.com,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH] sound: oss: ad1848: Fix returned errno code in ad1848_init()
Date: Tue, 22 Sep 2015 22:16:42 +0530	[thread overview]
Message-ID: <20150922164642.GA14353@sudip-pc> (raw)
In-Reply-To: <1442936257-8988-1-git-send-email-luisbg@osg.samsung.com>

On Tue, Sep 22, 2015 at 04:37:37PM +0100, 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.
> 
> Smatch tool warning:
> ad1848_init() warn: returning -1 instead of -ENOMEM is sloppy
> 
> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
> ---
>  sound/oss/ad1848.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c
> index 10c8de1..6b35656 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;
 The return value of ad1848_init is stored in hw_config->slots[0].
And in sound/oss/pss.c hw_config->slots[0] is checked like: 
if (hw_config->slots[0] != -1)

So, you just changed the functionality of the driver.

regards
sudip

  reply	other threads:[~2015-09-22 16:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 15:37 [PATCH] sound: oss: ad1848: Fix returned errno code in ad1848_init() Luis de Bethencourt
2015-09-22 16:46 ` Sudip Mukherjee [this message]
2015-09-22 16:46   ` Sudip Mukherjee
2015-09-22 19:11   ` Luis de Bethencourt
2015-09-23  6:26     ` Sudip Mukherjee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150922164642.GA14353@sudip-pc \
    --to=sudipm.mukherjee@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luisbg@osg.samsung.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.