From: Takashi Iwai <tiwai@suse.de>
To: Vladis Dronov <vdronov@redhat.com>
Cc: alsa-devel@alsa-project.org, Jaroslav Kysela <perex@perex.cz>,
linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: usb-audio: Fix double-free in snd_usb_add_audio_stream()
Date: Wed, 30 Mar 2016 20:31:15 +0000 [thread overview]
Message-ID: <s5hbn5v7lnw.wl-tiwai@suse.de> (raw)
In-Reply-To: <1459364602-28997-2-git-send-email-vdronov@redhat.com>
On Wed, 30 Mar 2016 21:03:22 +0200,
Vladis Dronov wrote:
>
> There is a double-free bug in [snd-usb-audio] module due to alloc/free logic
> flaw in snd_usb_add_audio_stream() function. This leads to kernel structures
> corruption and panic. Fix the code flow and alloc/free logic so there is no
> double-free.
>
> The detailed analysis: https://bugzilla.redhat.com/show_bug.cgi?id\x1283358
>
> Reported-by: Ralf Spenneberg <ralf@spenneberg.net>
> Signed-off-by: Vladis Dronov <vdronov@redhat.com>
Thanks for the report. But how about a simpler fix like below?
Takashi
---
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index fb62bce2435c..0e154ae7924e 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -150,6 +150,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
usb_audio_err(chip, "cannot memdup\n");
return -ENOMEM;
}
+ INIT_LIST_HEAD(&fp->list);
if (fp->nr_rates > MAX_NR_RATES) {
kfree(fp);
return -EINVAL;
@@ -193,8 +194,11 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
return 0;
error:
- kfree(fp);
- kfree(rate_table);
+ /* linked fp will be removed in snd_usb_audio_pcm_free() */
+ if (list_empty(&fp->list)) {
+ kfree(fp);
+ kfree(rate_table);
+ }
return err;
}
next prev parent reply other threads:[~2016-03-30 20:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 19:03 [PATCH] ALSA: usb-audio: Fix double-free in snd_usb_add_audio_stream() Vladis Dronov
2016-03-30 19:03 ` Vladis Dronov
2016-03-30 20:31 ` Takashi Iwai [this message]
2016-03-31 9:50 ` Takashi Iwai
2016-03-31 12:36 ` Vladis Dronov
2016-03-31 12:57 ` Takashi Iwai
2016-03-31 14:03 ` Vladis Dronov
2016-03-31 14:20 ` Takashi Iwai
2016-03-31 16:05 ` Vladis Dronov
2016-03-31 16:13 ` Takashi Iwai
2016-03-30 19:38 ` kbuild test robot
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=s5hbn5v7lnw.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=vdronov@redhat.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