Commit e497ec26 authored by Wenwen Wang's avatar Wenwen Wang Committed by Greg Kroah-Hartman

led: triggers: Fix a memory leak bug

[ Upstream commit 60e2dde1 ]

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: 52c47742 ("leds: triggers: send uevent when changing triggers")
Signed-off-by: default avatarWenwen Wang <wenwen@cs.uga.edu>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 83c2a42b
......@@ -177,6 +177,7 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment