Some functions for quirks of Tascam US-16x08 have memory leaks. This commit fixes the bugs. Fixes: d2bb390a2081 ("ALSA: usb-audio: Tascam US-16x08 DSP mixer quirk") Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx> --- sound/usb/mixer_us16x08.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c index 5dae63c..d34dd1c 100644 --- a/sound/usb/mixer_us16x08.c +++ b/sound/usb/mixer_us16x08.c @@ -1082,8 +1082,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer, kctl = snd_ctl_new1(ncontrol, elem); if (!kctl) { - kfree(elem); - return -ENOMEM; + err = -ENOMEM; + goto end; } kctl->private_free = freeer; @@ -1092,11 +1092,12 @@ static int add_new_ctl(struct usb_mixer_interface *mixer, err = snd_usb_mixer_add_control(&elem->head, kctl); if (err < 0) - return err; + goto end; if (elem_ret) *elem_ret = elem; - +end: + kfree(elem); return 0; } @@ -1367,7 +1368,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) usb_audio_dbg(mixer->chip, "Failed to create route control, err:%d\n", err); - return err; + goto err_allocated; } for (i = 0; i < 8; i++) elem->cache_val[i] = i < 2 ? i : i + 2; @@ -1388,7 +1389,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) comp_store, master_controls[i].freeer, &elem); if (err < 0) - return err; + goto err_allocated; elem->cache_val[0] = master_controls[i].default_val; elem->cached = 1; } @@ -1408,7 +1409,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) comp_store, channel_controls[i].freeer, &elem); if (err < 0) - return err; + goto err_allocated; for (j = 0; j < SND_US16X08_MAX_CHANNELS; j++) { elem->cache_val[j] = channel_controls[i].default_val; @@ -1429,7 +1430,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) eq_store, eq_controls[i].freeer, NULL); if (err < 0) - return err; + goto err_allocated; } /* add compressor controls */ @@ -1447,7 +1448,7 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) comp_store, comp_controls[i].freeer, NULL); if (err < 0) - return err; + goto err_allocated; } /* meter function 'get' must access to compressor store @@ -1458,9 +1459,13 @@ int snd_us16x08_controls_create(struct usb_mixer_interface *mixer) SND_US16X08_ID_METER, USB_MIXER_U16, 0, "Level Meter", (void *) meter_store, snd_usb_mixer_elem_free, NULL); if (err < 0) - return err; + goto err_allocated; } return 0; +err_allocated: + kfree(meter_store); + kfree(eq_store); + kfree(comp_store); + return err; } - -- 2.9.3 _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel