lkml.org 
[lkml]   [2021]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] ALSA: control led: fix memory leak in snd_ctl_led_register
On Fri, May 28, 2021 at 09:50:49PM +0800, Dongliang Mu wrote:
>
> Can you please give some advise on how to fix this WARN issue?

But it feels like it spoils the fun if I write the commit... Anyway:

regards,
dan carpenter

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 25f57c14f294..dd357abc1b58 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -740,6 +740,7 @@ static int __init snd_ctl_led_init(void)
for (; group > 0; group--) {
led = &snd_ctl_leds[group - 1];
device_del(&led->dev);
+ device_put(&led->dev);
}
device_del(&snd_ctl_led_dev);
return -ENOMEM;
@@ -768,6 +769,7 @@ static void __exit snd_ctl_led_exit(void)
for (group = 0; group < MAX_LED; group++) {
led = &snd_ctl_leds[group];
device_del(&led->dev);
+ device_put(&led->dev);
}
device_del(&snd_ctl_led_dev);
snd_ctl_led_clean(NULL);
\
 
 \ /
  Last update: 2021-05-28 16:07    [W:0.069 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site