All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: core: control_led: fix memory leak in snd_ctl_led_set_state()
@ 2021-04-04  6:40 Takashi Sakamoto
  2021-04-04  8:16 ` Jaroslav Kysela
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Sakamoto @ 2021-04-04  6:40 UTC (permalink / raw)
  To: tiwai, perex; +Cc: alsa-devel

When inquired control element is not in led group, snd_ctl_led_set_state()
attempts to add the element into the group, according to function
arguments. Although an memory object is allocated for led instance, it's
left as is without being released.

This commit fixes the memory leak.

Fixes: 22d8de62f11b ("ALSA: control - add generic LED trigger module as the new control layer")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/core/control_led.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 788fd9e275e0..b97f118cd54e 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -161,6 +161,7 @@ static void snd_ctl_led_set_state(struct snd_card *card, unsigned int access,
 			list_add(&lctl->list, &led->controls);
 			UPDATE_ROUTE(route, snd_ctl_led_get(lctl));
 		}
+		kfree(lctl);
 	}
 	mutex_unlock(&snd_ctl_led_mutex);
 	switch (led->mode) {
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-06  1:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-04  6:40 [PATCH] ALSA: core: control_led: fix memory leak in snd_ctl_led_set_state() Takashi Sakamoto
2021-04-04  8:16 ` Jaroslav Kysela
2021-04-06  1:16   ` Takashi Sakamoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.