From: Jacek Anaszewski Date: Sun, 18 Sep 2016 18:24:29 +0000 (+0200) Subject: leds: triggers: Return from led_trigger_set() if there is nothing to do X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=fbfa197afddd13f9bdca1c822f5d5730b50639eb;p=linux-beck.git leds: triggers: Return from led_trigger_set() if there is nothing to do If led_trigger_set() is called with "trig" argument set to NULL, and there is no trigger to remove then the function should return immediately so as to avoid doing unnecessary allocation and sending uevent. Signed-off-by: Jacek Anaszewski Reported-by: Daniel Romell Acked-by Daniel Romell --- diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index 59d6a3e58a3d..c7a38d43ff62 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -110,6 +110,9 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) char *envp[2]; const char *name; + if (!led_cdev->trigger && !trig) + return; + name = trig ? trig->name : "none"; event = kasprintf(GFP_KERNEL, "TRIGGER=%s", name);