Alsa-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
	Takashi Iwai <tiwai@suse.com>
Subject: [PATCH 1/2] ALSA: control - fix a leak in snd_ctl_led_init()
Date: Fri, 2 Apr 2021 14:42:09 +0300
Message-ID: <YGcDETcdqVUIl1+y@mwanda> (raw)

This unwind loop needs to free snd_ctl_leds[0] as well.

Fixes: cb17fe0045aa ("ALSA: control - add sysfs support to the LED trigger module")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/core/control_led.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index d4fb8b873f34..202b475d0bf3 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -712,7 +712,7 @@ static struct snd_ctl_layer_ops snd_ctl_led_lops = {
 static int __init snd_ctl_led_init(void)
 {
 	struct snd_ctl_led *led;
-	unsigned int group;
+	int group;
 
 	device_initialize(&snd_ctl_led_dev);
 	snd_ctl_led_dev.class = sound_class;
@@ -730,7 +730,7 @@ static int __init snd_ctl_led_init(void)
 		dev_set_name(&led->dev, led->name);
 		if (device_add(&led->dev)) {
 			put_device(&led->dev);
-			for (; group > 0; group--) {
+			for (; group >= 0; group--) {
 				led = &snd_ctl_leds[group];
 				device_del(&led->dev);
 			}
-- 
2.30.2


             reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 11:42 Dan Carpenter [this message]
2021-04-02 11:42 ` [PATCH 2/2] ALSA: control - off by one in store_mode() Dan Carpenter
2021-04-02 17:52   ` Jaroslav Kysela
2021-04-06 11:34     ` Takashi Iwai
2021-04-02 17:57 ` [PATCH 1/2] ALSA: control - fix a leak in snd_ctl_led_init() Jaroslav Kysela
2021-04-09 12:34   ` [PATCH 1/2 v2] ALSA: control - double free " Dan Carpenter
2021-04-09 13:12     ` Jaroslav Kysela
2021-04-09 14:16     ` Takashi Iwai

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=YGcDETcdqVUIl1+y@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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

Alsa-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/alsa-devel/0 alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ https://lore.kernel.org/alsa-devel \
		alsa-devel@alsa-project.org
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.alsa-project.alsa-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git