led: triggers: Fix a memory leak bug

In led_trigger_set(), 'event' is allocated in kasprintf(). However, it is
not deallocated in the following execution if the label 'err_activate' or
'err_add_groups' is entered, leading to memory leaks. To fix this issue,
free 'event' before returning the error.

Fixes: 52c47742f7 ("leds: triggers: send uevent when changing triggers")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
This commit is contained in:
Wenwen Wang 2019-08-19 15:41:42 -05:00 committed by Jacek Anaszewski
parent 3881a72f8d
commit 60e2dde1e9
1 changed files with 1 additions and 0 deletions

View File

@ -173,6 +173,7 @@ err_activate:
list_del(&led_cdev->trig_list);
write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags);
led_set_brightness(led_cdev, LED_OFF);
kfree(event);
return ret;
}