]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
The memory for struct led_trigger should be kfreed in the
authorMasakazu Mokuno <Masakazu.Mokuno@jp.sony.com>
Wed, 24 Aug 2011 23:47:36 +0000 (09:47 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 1 Sep 2011 03:28:57 +0000 (13:28 +1000)
led_trigger_register() error path.  Also this function should return NULL
on error.

Signed-off-by: Masakazu Mokuno <mokuno@sm.sony.co.jp>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/leds/led-triggers.c

index 4bebae733349b90f84230d1b4454942cc9744451..6f1ff93d7cec32862e5cdc7b998586381c401f1c 100644 (file)
@@ -261,9 +261,12 @@ void led_trigger_register_simple(const char *name, struct led_trigger **tp)
        if (trigger) {
                trigger->name = name;
                err = led_trigger_register(trigger);
-               if (err < 0)
+               if (err < 0) {
+                       kfree(trigger);
+                       trigger = NULL;
                        printk(KERN_WARNING "LED trigger %s failed to register"
                                " (%d)\n", name, err);
+               }
        } else
                printk(KERN_WARNING "LED trigger %s failed to register"
                        " (no memory)\n", name);