Commit b591b6e9 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: core: Don't ignore errors at creating proc files

So far we've ignored the errors at creating proc files in many places.
But they should be rather treated seriously.

Also, by assuring the error handling, we can get rid of superfluous
snd_info_free_entry() calls as they will be removed by the parent in
the caller side.

This patch fixes the missing error checks and reduces the superfluous
free calls.
Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b046d244
...@@ -482,10 +482,11 @@ int __init snd_info_init(void) ...@@ -482,10 +482,11 @@ int __init snd_info_init(void)
if (!snd_seq_root) if (!snd_seq_root)
goto error; goto error;
#endif #endif
snd_info_version_init(); if (snd_info_version_init() < 0 ||
snd_minor_info_init(); snd_minor_info_init() < 0 ||
snd_minor_info_oss_init(); snd_minor_info_oss_init() < 0 ||
snd_card_info_init(); snd_card_info_init() < 0)
goto error;
return 0; return 0;
error: error:
...@@ -847,11 +848,7 @@ static int __init snd_info_version_init(void) ...@@ -847,11 +848,7 @@ static int __init snd_info_version_init(void)
if (entry == NULL) if (entry == NULL)
return -ENOMEM; return -ENOMEM;
entry->c.text.read = snd_info_version_read; entry->c.text.read = snd_info_version_read;
if (snd_info_register(entry) < 0) { return snd_info_register(entry); /* freed in error path */
snd_info_free_entry(entry);
return -ENOMEM;
}
return 0;
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
...@@ -853,18 +853,16 @@ int __init snd_card_info_init(void) ...@@ -853,18 +853,16 @@ int __init snd_card_info_init(void)
if (! entry) if (! entry)
return -ENOMEM; return -ENOMEM;
entry->c.text.read = snd_card_info_read; entry->c.text.read = snd_card_info_read;
if (snd_info_register(entry) < 0) { if (snd_info_register(entry) < 0)
snd_info_free_entry(entry); return -ENOMEM; /* freed in error path */
return -ENOMEM;
}
#ifdef MODULE #ifdef MODULE
entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL); entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL);
if (entry) { if (!entry)
entry->c.text.read = snd_card_module_info_read; return -ENOMEM;
if (snd_info_register(entry) < 0) entry->c.text.read = snd_card_module_info_read;
snd_info_free_entry(entry); if (snd_info_register(entry) < 0)
} return -ENOMEM; /* freed in error path */
#endif #endif
return 0; return 0;
......
...@@ -51,6 +51,13 @@ create_info_entry(char *name, void (*read)(struct snd_info_entry *, ...@@ -51,6 +51,13 @@ create_info_entry(char *name, void (*read)(struct snd_info_entry *,
return entry; return entry;
} }
static void free_info_entries(void)
{
snd_info_free_entry(queues_entry);
snd_info_free_entry(clients_entry);
snd_info_free_entry(timer_entry);
}
/* create all our /proc entries */ /* create all our /proc entries */
int __init snd_seq_info_init(void) int __init snd_seq_info_init(void)
{ {
...@@ -59,14 +66,18 @@ int __init snd_seq_info_init(void) ...@@ -59,14 +66,18 @@ int __init snd_seq_info_init(void)
clients_entry = create_info_entry("clients", clients_entry = create_info_entry("clients",
snd_seq_info_clients_read); snd_seq_info_clients_read);
timer_entry = create_info_entry("timer", snd_seq_info_timer_read); timer_entry = create_info_entry("timer", snd_seq_info_timer_read);
if (!queues_entry || !clients_entry || !timer_entry)
goto error;
return 0; return 0;
error:
free_info_entries();
return -ENOMEM;
} }
int __exit snd_seq_info_done(void) int __exit snd_seq_info_done(void)
{ {
snd_info_free_entry(queues_entry); free_info_entries();
snd_info_free_entry(clients_entry);
snd_info_free_entry(timer_entry);
return 0; return 0;
} }
#endif #endif
...@@ -386,14 +386,10 @@ int __init snd_minor_info_init(void) ...@@ -386,14 +386,10 @@ int __init snd_minor_info_init(void)
struct snd_info_entry *entry; struct snd_info_entry *entry;
entry = snd_info_create_module_entry(THIS_MODULE, "devices", NULL); entry = snd_info_create_module_entry(THIS_MODULE, "devices", NULL);
if (entry) { if (!entry)
entry->c.text.read = snd_minor_info_read; return -ENOMEM;
if (snd_info_register(entry) < 0) { entry->c.text.read = snd_minor_info_read;
snd_info_free_entry(entry); return snd_info_register(entry); /* freed in error path */
entry = NULL;
}
}
return 0;
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
......
...@@ -260,12 +260,10 @@ int __init snd_minor_info_oss_init(void) ...@@ -260,12 +260,10 @@ int __init snd_minor_info_oss_init(void)
struct snd_info_entry *entry; struct snd_info_entry *entry;
entry = snd_info_create_module_entry(THIS_MODULE, "devices", snd_oss_root); entry = snd_info_create_module_entry(THIS_MODULE, "devices", snd_oss_root);
if (entry) { if (!entry)
entry->c.text.read = snd_minor_info_oss_read; return -ENOMEM;
if (snd_info_register(entry) < 0) entry->c.text.read = snd_minor_info_oss_read;
snd_info_free_entry(entry); return snd_info_register(entry); /* freed in error path */
}
return 0;
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment