summaryrefslogtreecommitdiff
path: root/drivers/leds/led-triggers.c
diff options
context:
space:
mode:
authorMasakazu Mokuno <Masakazu.Mokuno@jp.sony.com>2011-10-31 17:11:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-31 17:30:55 -0700
commitcba4c2ac080e170732a030afc27664b00f838e03 (patch)
treeb230c60335225f533b10b570f323662f7ed9cfe0 /drivers/leds/led-triggers.c
parentf59b6f9f323ff1b4567a69f9063cdd8bb57805e6 (diff)
downloadlinux-3.10-cba4c2ac080e170732a030afc27664b00f838e03.tar.gz
linux-3.10-cba4c2ac080e170732a030afc27664b00f838e03.tar.bz2
linux-3.10-cba4c2ac080e170732a030afc27664b00f838e03.zip
drivers/leds/led-triggers.c: fix memory leak
The memory for struct led_trigger should be kfreed in the 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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds/led-triggers.c')
-rw-r--r--drivers/leds/led-triggers.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 4bebae73334..6f1ff93d7ce 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -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);