From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Wenwen Wang <wenwen@cs.uga.edu>, Pavel Machek <pavel@ucw.cz>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>,
Sasha Levin <sashal@kernel.org>,
linux-leds@vger.kernel.org
Subject: [PATCH AUTOSEL 5.2 091/185] led: triggers: Fix a memory leak bug
Date: Sun, 22 Sep 2019 14:47:49 -0400 [thread overview]
Message-ID: <20190922184924.32534-91-sashal@kernel.org> (raw)
In-Reply-To: <20190922184924.32534-1-sashal@kernel.org>
From: Wenwen Wang <wenwen@cs.uga.edu>
[ Upstream commit 60e2dde1e91ae0addb21ac380cc36ebee7534e49 ]
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: 52c47742f79d ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 8d11a5e232271..eff1bda8b5200 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.20.1
next prev parent reply other threads:[~2019-09-22 19:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190922184924.32534-1-sashal@kernel.org>
2019-09-22 18:46 ` [PATCH AUTOSEL 5.2 011/185] leds: leds-lp5562 allow firmware files up to the maximum length Sasha Levin
2019-09-22 18:47 ` Sasha Levin [this message]
2019-09-22 18:48 ` [PATCH AUTOSEL 5.2 121/185] leds: lm3532: Fixes for the driver for stability Sasha Levin
2019-10-02 19:16 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190922184924.32534-91-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=stable@vger.kernel.org \
--cc=wenwen@cs.uga.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).