staging: speakup: fix memory leak
authorVasiliy Kulikov <segooon@gmail.com>
Sun, 17 Oct 2010 14:51:57 +0000 (18:51 +0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 19 Oct 2010 17:10:54 +0000 (10:10 -0700)
speakup_init() didn't free first_console if speakup_kobj_init() fails.
Also propagate speakup_kobj_init()'s return code.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/speakup/main.c

index a64704bd19bf4b1fb0b58398bcc676b8f9cf0d18..4b7a9c2b965fd0e958d22603ea790b21e80801f2 100644 (file)
@@ -2259,8 +2259,11 @@ static int __init speakup_init(void)
        first_console = kzalloc(sizeof(*first_console), GFP_KERNEL);
        if (!first_console)
                return -ENOMEM;
-       if (speakup_kobj_init() < 0)
-               return -ENOMEM;
+       err = speakup_kobj_init();
+       if (err) {
+               kfree(first_console);
+               return err;
+       }
 
        reset_default_chars();
        reset_default_chartab();