From: Jaroslav Kysela <perex@perex.cz>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
Takashi Iwai <tiwai@suse.com>
Subject: Re: [PATCH 1/2 v2] ALSA: control - double free in snd_ctl_led_init()
Date: Fri, 9 Apr 2021 15:12:25 +0200 [thread overview]
Message-ID: <001a23ae-12de-5d7a-1095-4ab908841cd0@perex.cz> (raw)
In-Reply-To: <YHBJ4frGxErWB182@mwanda>
Dne 09. 04. 21 v 14:34 Dan Carpenter napsal(a):
> "group - 1" was intended here instead of "group". The current error
> handling will double free the first item in the array and leak the last
> item.
>
> Fixes: cb17fe0045aa ("ALSA: control - add sysfs support to the LED trigger module")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
> ---
> v2: The first patch wasn't right. It fixed the leak but left the double
> free.
>
> sound/core/control_led.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/core/control_led.c b/sound/core/control_led.c
> index d756a52e58db..93b201063c7d 100644
> --- a/sound/core/control_led.c
> +++ b/sound/core/control_led.c
> @@ -734,7 +734,7 @@ static int __init snd_ctl_led_init(void)
> if (device_add(&led->dev)) {
> put_device(&led->dev);
> for (; group > 0; group--) {
> - led = &snd_ctl_leds[group];
> + led = &snd_ctl_leds[group - 1];
> device_del(&led->dev);
> }
> device_del(&snd_ctl_led_dev);
>
--
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
next prev parent reply other threads:[~2021-04-09 13:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-02 11:42 [PATCH 1/2] ALSA: control - fix a leak in snd_ctl_led_init() Dan Carpenter
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 [this message]
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=001a23ae-12de-5d7a-1095-4ab908841cd0@perex.cz \
--to=perex@perex.cz \
--cc=alsa-devel@alsa-project.org \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--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
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).