From ab5be93c75e8c423fc328202a42d88e4971b1a3a Mon Sep 17 00:00:00 2001 From: Masakazu Mokuno Date: Thu, 25 Aug 2011 09:47:36 +1000 Subject: [PATCH] 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 Cc: Richard Purdie Signed-off-by: Andrew Morton --- drivers/leds/led-triggers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 4bebae733349..6f1ff93d7cec 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); -- 2.39.5