diff mbox

[5/6] ALSA: usb-audio: Return -ENOMEM on memory alloc failure in format.c

Message ID 1353488819-13902-5-git-send-email-sachin.kamat@linaro.org
State Superseded
Headers show

Commit Message

Sachin Kamat Nov. 21, 2012, 9:06 a.m. UTC
Return -ENOMEM instead of -1 to silence the following smatch warning:
sound/usb/format.c:170 parse_audio_format_rates_v1() warn:
returning -1 instead of -ENOMEM is sloppy

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
Build tested and based on linux-next 20121115.
---
 sound/usb/format.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Takashi Iwai Nov. 21, 2012, 9:45 a.m. UTC | #1
At Wed, 21 Nov 2012 14:36:58 +0530,
Sachin Kamat wrote:
> 
> Return -ENOMEM instead of -1 to silence the following smatch warning:
> sound/usb/format.c:170 parse_audio_format_rates_v1() warn:
> returning -1 instead of -ENOMEM is sloppy
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

There are some other places returning -1 around this.
Could you fix them as well to sensitive values?


thanks,

Takashi


> ---
> Build tested and based on linux-next 20121115.
> ---
>  sound/usb/format.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/sound/usb/format.c b/sound/usb/format.c
> index ddfef57..d033d4d 100644
> --- a/sound/usb/format.c
> +++ b/sound/usb/format.c
> @@ -167,7 +167,7 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
>  		fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
>  		if (fp->rate_table == NULL) {
>  			snd_printk(KERN_ERR "cannot malloc\n");
> -			return -1;
> +			return -ENOMEM;
>  		}
>  
>  		fp->nr_rates = 0;
> -- 
> 1.7.4.1
>
Sachin Kamat Nov. 21, 2012, 9:56 a.m. UTC | #2
On 21 November 2012 15:15, Takashi Iwai <tiwai@suse.de> wrote:
> At Wed, 21 Nov 2012 14:36:58 +0530,
> Sachin Kamat wrote:
>>
>> Return -ENOMEM instead of -1 to silence the following smatch warning:
>> sound/usb/format.c:170 parse_audio_format_rates_v1() warn:
>> returning -1 instead of -ENOMEM is sloppy
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>
> There are some other places returning -1 around this.
> Could you fix them as well to sensitive values?

Ok. Will update and re-send this patch.
>
>
> thanks,
>
> Takashi
>
>
>> ---
>> Build tested and based on linux-next 20121115.
>> ---
>>  sound/usb/format.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/sound/usb/format.c b/sound/usb/format.c
>> index ddfef57..d033d4d 100644
>> --- a/sound/usb/format.c
>> +++ b/sound/usb/format.c
>> @@ -167,7 +167,7 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
>>               fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
>>               if (fp->rate_table == NULL) {
>>                       snd_printk(KERN_ERR "cannot malloc\n");
>> -                     return -1;
>> +                     return -ENOMEM;
>>               }
>>
>>               fp->nr_rates = 0;
>> --
>> 1.7.4.1
>>
diff mbox

Patch

diff --git a/sound/usb/format.c b/sound/usb/format.c
index ddfef57..d033d4d 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -167,7 +167,7 @@  static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
 		fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
 		if (fp->rate_table == NULL) {
 			snd_printk(KERN_ERR "cannot malloc\n");
-			return -1;
+			return -ENOMEM;
 		}
 
 		fp->nr_rates = 0;