leds: triggers: Return from led_trigger_set() if there is nothing to do
authorJacek Anaszewski <jacek.anaszewski@gmail.com>
Sun, 18 Sep 2016 18:24:29 +0000 (20:24 +0200)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Tue, 20 Sep 2016 08:21:17 +0000 (10:21 +0200)
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 <j.anaszewski@samsung.com>
Reported-by: Daniel Romell <daro@hms.se>
Acked-by Daniel Romell <daro@hms.se>

drivers/leds/led-triggers.c

index 59d6a3e58a3d9c72074f012b9c3cbc74bcecb1ba..c7a38d43ff623d7c6591c81f619d45aa6a00d52c 100644 (file)
@@ -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);