* [PATCH] ALSA: Fix uninintialized error return
@ 2015-06-29 16:10 Colin King
2015-06-29 17:10 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2015-06-29 16:10 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai, Mark Brown, Jie Yang, alsa-devel
Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Static analysis with cppcheck found the following error:
[sound/core/init.c:118]: (error) Uninitialized variable: err
..this was introduced by commit 2471b6c80a70e80de69f5ff4c37187c3912e5874
("ALSA: info: Register proc entries recursively, too") where the call
to snd_info_card_register was removed and no longer setting the error
return in err. When snd_info_create_card_entry fails to allocate a
an entry, the error path exits with garbage in err. Fix is to return
-ENOMEM if entry fails to be allocated.
Author: Takashi Iwai <tiwai@suse.de>
Date: Mon May 18 09:20:24 2015 +0200
Fixes: 2471b6c80a ("ALSA: info: Register proc entries recursively, too")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
sound/core/init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/core/init.c b/sound/core/init.c
index 3e0ceba..20f37fb 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -109,13 +109,12 @@ static void snd_card_id_read(struct snd_info_entry *entry,
static int init_info_for_card(struct snd_card *card)
{
- int err;
struct snd_info_entry *entry;
entry = snd_info_create_card_entry(card, "id", card->proc_root);
if (!entry) {
dev_dbg(card->dev, "unable to create card entry\n");
- return err;
+ return -ENOMEM;
}
entry->c.text.read = snd_card_id_read;
card->proc_id = entry;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ALSA: Fix uninintialized error return
2015-06-29 16:10 [PATCH] ALSA: Fix uninintialized error return Colin King
@ 2015-06-29 17:10 ` Takashi Iwai
2015-06-30 6:22 ` Colin Ian King
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2015-06-29 17:10 UTC (permalink / raw)
To: Colin King
Cc: Jaroslav Kysela, Mark Brown, Jie Yang, alsa-devel, linux-kernel
At Mon, 29 Jun 2015 17:10:22 +0100,
Colin King wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Static analysis with cppcheck found the following error:
> [sound/core/init.c:118]: (error) Uninitialized variable: err
>
> ..this was introduced by commit 2471b6c80a70e80de69f5ff4c37187c3912e5874
> ("ALSA: info: Register proc entries recursively, too") where the call
> to snd_info_card_register was removed and no longer setting the error
> return in err. When snd_info_create_card_entry fails to allocate a
> an entry, the error path exits with garbage in err. Fix is to return
> -ENOMEM if entry fails to be allocated.
>
> Author: Takashi Iwai <tiwai@suse.de>
> Date: Mon May 18 09:20:24 2015 +0200
These two lines seem superfluous. I removed them and applied the
patch now. Thanks.
Takashi
>
> Fixes: 2471b6c80a ("ALSA: info: Register proc entries recursively, too")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> sound/core/init.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/sound/core/init.c b/sound/core/init.c
> index 3e0ceba..20f37fb 100644
> --- a/sound/core/init.c
> +++ b/sound/core/init.c
> @@ -109,13 +109,12 @@ static void snd_card_id_read(struct snd_info_entry *entry,
>
> static int init_info_for_card(struct snd_card *card)
> {
> - int err;
> struct snd_info_entry *entry;
>
> entry = snd_info_create_card_entry(card, "id", card->proc_root);
> if (!entry) {
> dev_dbg(card->dev, "unable to create card entry\n");
> - return err;
> + return -ENOMEM;
> }
> entry->c.text.read = snd_card_id_read;
> card->proc_id = entry;
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ALSA: Fix uninintialized error return
2015-06-29 17:10 ` Takashi Iwai
@ 2015-06-30 6:22 ` Colin Ian King
0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2015-06-30 6:22 UTC (permalink / raw)
To: Takashi Iwai
Cc: Jaroslav Kysela, Mark Brown, Jie Yang, alsa-devel, linux-kernel
On 29/06/15 18:10, Takashi Iwai wrote:
> At Mon, 29 Jun 2015 17:10:22 +0100,
> Colin King wrote:
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Static analysis with cppcheck found the following error:
>> [sound/core/init.c:118]: (error) Uninitialized variable: err
>>
>> ..this was introduced by commit 2471b6c80a70e80de69f5ff4c37187c3912e5874
>> ("ALSA: info: Register proc entries recursively, too") where the call
>> to snd_info_card_register was removed and no longer setting the error
>> return in err. When snd_info_create_card_entry fails to allocate a
>> an entry, the error path exits with garbage in err. Fix is to return
>> -ENOMEM if entry fails to be allocated.
>>
>> Author: Takashi Iwai <tiwai@suse.de>
>> Date: Mon May 18 09:20:24 2015 +0200
>
> These two lines seem superfluous. I removed them and applied the
> patch now. Thanks.
>
Thanks, somehow I missed that cut-n-paste mistake.
>
> Takashi
>
>>
>> Fixes: 2471b6c80a ("ALSA: info: Register proc entries recursively, too")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> sound/core/init.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/sound/core/init.c b/sound/core/init.c
>> index 3e0ceba..20f37fb 100644
>> --- a/sound/core/init.c
>> +++ b/sound/core/init.c
>> @@ -109,13 +109,12 @@ static void snd_card_id_read(struct snd_info_entry *entry,
>>
>> static int init_info_for_card(struct snd_card *card)
>> {
>> - int err;
>> struct snd_info_entry *entry;
>>
>> entry = snd_info_create_card_entry(card, "id", card->proc_root);
>> if (!entry) {
>> dev_dbg(card->dev, "unable to create card entry\n");
>> - return err;
>> + return -ENOMEM;
>> }
>> entry->c.text.read = snd_card_id_read;
>> card->proc_id = entry;
>> --
>> 2.1.4
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-30 6:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-29 16:10 [PATCH] ALSA: Fix uninintialized error return Colin King
2015-06-29 17:10 ` Takashi Iwai
2015-06-30 6:22 ` Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox