]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ALSA: seq: Fix leftovers at probe error path
authorTakashi Iwai <tiwai@suse.de>
Wed, 1 Aug 2018 14:37:02 +0000 (16:37 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 1 Aug 2018 20:54:36 +0000 (22:54 +0200)
The sequencer core module doesn't call some destructors in the error
path of the init code, which may leave some resources.

This patch mainly fix these leaks by calling the destructors
appropriately at alsa_seq_init().  Also the patch brings a few
cleanups along with it, namely:

- Expand the old "if ((err = xxx) < 0)" coding style
- Get rid of empty seq_queue_init() and its caller
- Change snd_seq_info_done() to void

Last but not least, a couple of functions lose __exit annotation since
they are called also in alsa_seq_init().

No functional changes but minor code cleanups.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/seq.c
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_info.c
sound/core/seq/seq_info.h
sound/core/seq/seq_queue.c
sound/core/seq/seq_queue.h

index e685eccdc741e2d38938095a85c31eb55b39aa50..7de98d71f2aa453e0089144ae3f44802def37b6d 100644 (file)
@@ -84,26 +84,32 @@ static int __init alsa_seq_init(void)
 {
        int err;
 
-       if ((err = client_init_data()) < 0)
-               goto error;
-
-       /* init event queues */
-       if ((err = snd_seq_queues_init()) < 0)
+       err = client_init_data();
+       if (err < 0)
                goto error;
 
        /* register sequencer device */
-       if ((err = snd_sequencer_device_init()) < 0)
+       err = snd_sequencer_device_init();
+       if (err < 0)
                goto error;
 
        /* register proc interface */
-       if ((err = snd_seq_info_init()) < 0)
-               goto error;
+       err = snd_seq_info_init();
+       if (err < 0)
+               goto error_device;
 
        /* register our internal client */
-       if ((err = snd_seq_system_client_init()) < 0)
-               goto error;
+       err = snd_seq_system_client_init();
+       if (err < 0)
+               goto error_info;
 
        snd_seq_autoload_init();
+       return 0;
+
+ error_info:
+       snd_seq_info_done();
+ error_device:
+       snd_sequencer_device_done();
  error:
        return err;
 }
index 6fd4b074b206f6557f36c00188ab417f87f9d394..a0b768e2f697b4add506c583f896adc636db7ec1 100644 (file)
@@ -2543,7 +2543,7 @@ int __init snd_sequencer_device_init(void)
 /* 
  * unregister sequencer device 
  */
-void __exit snd_sequencer_device_done(void)
+void snd_sequencer_device_done(void)
 {
        snd_unregister_device(&seq_dev);
        put_device(&seq_dev);
index 97015447b9b37856b642624a151892e7b2eb8d69..b27fedd435b60c3abff2e3dc28cd81ed99e48c44 100644 (file)
@@ -50,7 +50,7 @@ create_info_entry(char *name, void (*read)(struct snd_info_entry *,
        return entry;
 }
 
-static void free_info_entries(void)
+void snd_seq_info_done(void)
 {
        snd_info_free_entry(queues_entry);
        snd_info_free_entry(clients_entry);
@@ -70,12 +70,6 @@ int __init snd_seq_info_init(void)
        return 0;
 
  error:
-       free_info_entries();
+       snd_seq_info_done();
        return -ENOMEM;
 }
-
-int __exit snd_seq_info_done(void)
-{
-       free_info_entries();
-       return 0;
-}
index f8549f81a645646c57f75afa461b56613634055a..2cdf8f6e63f560adc93bc2e8b44ac4cc743a048f 100644 (file)
@@ -30,11 +30,11 @@ void snd_seq_info_queues_read(struct snd_info_entry *entry, struct snd_info_buff
 
 
 #ifdef CONFIG_SND_PROC_FS
-int snd_seq_info_init( void );
-int snd_seq_info_done( void );
+int snd_seq_info_init(void);
+void snd_seq_info_done(void);
 #else
 static inline int snd_seq_info_init(void) { return 0; }
-static inline int snd_seq_info_done(void) { return 0; }
+static inline void snd_seq_info_done(void) {}
 #endif
 
 #endif
index b377f50483529e969dbd65cdea65f0ab80e01863..3b3ac96f1f5f2eace0c0a3d939164b778567ec03 100644 (file)
@@ -159,18 +159,8 @@ static void queue_delete(struct snd_seq_queue *q)
 
 /*----------------------------------------------------------------*/
 
-/* setup queues */
-int __init snd_seq_queues_init(void)
-{
-       /*
-       memset(queue_list, 0, sizeof(queue_list));
-       num_queues = 0;
-       */
-       return 0;
-}
-
 /* delete all existing queues */
-void __exit snd_seq_queues_delete(void)
+void snd_seq_queues_delete(void)
 {
        int i;
 
index 719093489a2c4eec57fed70d4ba2b862cb64a9cf..76db43b79a2bf2904556938c1f064c00a98a15fd 100644 (file)
@@ -63,9 +63,6 @@ struct snd_seq_queue {
 /* get the number of current queues */
 int snd_seq_queue_get_cur_queues(void);
 
-/* init queues structure */
-int snd_seq_queues_init(void);
-
 /* delete queues */ 
 void snd_seq_queues_delete(void);