ALSA: usb-audio: fix rate_list memory leak
authorClemens Ladisch <clemens@ladisch.de>
Fri, 18 May 2012 16:00:43 +0000 (18:00 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 31 May 2012 08:25:44 +0000 (10:25 +0200)
The array of sample rates is reallocated every time when opening
the PCM device, but was freed only once when unplugging the device.

Reported-by: "Alexander E. Patrakov" <patrakov@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/pcm.c

index 24839d932648c81849ecfe63214a8124d914dd0e..cdf8b7601973406c445c69c6e5cd4afbdbbdf23b 100644 (file)
@@ -788,6 +788,9 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
        int count = 0, needs_knot = 0;
        int err;
 
+       kfree(subs->rate_list.list);
+       subs->rate_list.list = NULL;
+
        list_for_each_entry(fp, &subs->fmt_list, list) {
                if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS)
                        return 0;