Commit 6cd17ea7 authored by Ruslan Bilovol's avatar Ruslan Bilovol Committed by Takashi Iwai

ALSA: usb: stream: fix potential memory leak during uac3 interface parsing

UAC3 channel map is created during interface parsing,
and in some cases was not freed in failure paths.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarRuslan Bilovol <ruslan.bilovol@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 11d42c81
...@@ -982,13 +982,16 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip, ...@@ -982,13 +982,16 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
dev_err(&dev->dev, "%u:%d : bogus bTerminalLink %d\n", dev_err(&dev->dev, "%u:%d : bogus bTerminalLink %d\n",
iface_no, altno, as->bTerminalLink); iface_no, altno, as->bTerminalLink);
kfree(chmap);
return NULL; return NULL;
found_clock: found_clock:
fp = audio_format_alloc_init(chip, alts, UAC_VERSION_3, iface_no, fp = audio_format_alloc_init(chip, alts, UAC_VERSION_3, iface_no,
altset_idx, altno, num_channels, clock); altset_idx, altno, num_channels, clock);
if (!fp) if (!fp) {
kfree(chmap);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
}
fp->chmap = chmap; fp->chmap = chmap;
...@@ -1009,6 +1012,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip, ...@@ -1009,6 +1012,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
iface_no); iface_no);
/* ok, let's parse further... */ /* ok, let's parse further... */
if (snd_usb_parse_audio_format_v3(chip, fp, as, stream) < 0) { if (snd_usb_parse_audio_format_v3(chip, fp, as, stream) < 0) {
kfree(fp->chmap);
kfree(fp->rate_table); kfree(fp->rate_table);
kfree(fp); kfree(fp);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment