[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1566247302-6217-1-git-send-email-wenwen@cs.uga.edu>
Date: Mon, 19 Aug 2019 15:41:42 -0500
From: Wenwen Wang <wenwen@...uga.edu>
To: Wenwen Wang <wenwen@...uga.edu>
Cc: Jacek Anaszewski <jacek.anaszewski@...il.com>,
Pavel Machek <pavel@....cz>, Dan Murphy <dmurphy@...com>,
linux-leds@...r.kernel.org (open list:LED SUBSYSTEM),
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH] 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.
Signed-off-by: Wenwen Wang <wenwen@...uga.edu>
---
drivers/leds/led-triggers.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 8d11a5e..eff1bda 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -173,6 +173,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;
}
--
2.7.4
Powered by blists - more mailing lists