[<prev] [next>] [day] [month] [year] [list]
Message-Id: <201108100731.p7A7VdcA000020@imail.sm.sony.co.jp>
Date: Wed, 10 Aug 2011 16:31:36 +0900
From: Masakazu Mokuno <Masakazu.Mokuno@...sony.com>
To: Richard Purdie <rpurdie@...ys.net>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] led: fix memory leak
led: fix memory leak
The memory for struct led_trigger should be properly kfreed in the case of
error of led_trigger_register(). Also this function should return NULL if
error.
Signed-off-by: Masakazu Mokuno <mokuno@...sony.co.jp>
---
drivers/leds/led-triggers.c | 5 4 + 1 - 0 !
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -261,9 +261,12 @@ void led_trigger_register_simple(const c
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);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists