OSDN Git Service

ALSA: usb: stream: fix potential memory leak during uac3 interface parsing
authorRuslan Bilovol <ruslan.bilovol@gmail.com>
Thu, 17 May 2018 22:08:59 +0000 (01:08 +0300)
committerTakashi Iwai <tiwai@suse.de>
Fri, 18 May 2018 06:40:40 +0000 (08:40 +0200)
UAC3 channel map is created during interface parsing,
and in some cases was not freed in failure paths.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/stream.c

index bce3152..d16e1c2 100644 (file)
@@ -982,13 +982,16 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
 
        dev_err(&dev->dev, "%u:%d : bogus bTerminalLink %d\n",
                        iface_no, altno, as->bTerminalLink);
+       kfree(chmap);
        return NULL;
 
 found_clock:
        fp = audio_format_alloc_init(chip, alts, UAC_VERSION_3, iface_no,
                                     altset_idx, altno, num_channels, clock);
-       if (!fp)
+       if (!fp) {
+               kfree(chmap);
                return ERR_PTR(-ENOMEM);
+       }
 
        fp->chmap = chmap;
 
@@ -1009,6 +1012,7 @@ found_clock:
                                                               iface_no);
                /* ok, let's parse further... */
                if (snd_usb_parse_audio_format_v3(chip, fp, as, stream) < 0) {
+                       kfree(fp->chmap);
                        kfree(fp->rate_table);
                        kfree(fp);
                        return NULL;