leds: Fix trigger unregister_simple if register_simple fails
Fix led_trigger_unregister_simple to handle the case where
led_trigger_register_simple fails, avoiding a NULL pointer
dereference.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 454fb09..129733f 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -215,7 +215,8 @@
void led_trigger_unregister_simple(struct led_trigger *trigger)
{
- led_trigger_unregister(trigger);
+ if (trigger)
+ led_trigger_unregister(trigger);
kfree(trigger);
}