]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
ALSA: usb-audio: Fix a memory leak bug
authorWenwen Wang <wang6495@umn.edu>
Sat, 27 Apr 2019 06:06:46 +0000 (01:06 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commitcc3648e4a5ee46053fdd4b45b91debfe689446bf
tree1940882c7324e9ebaedb7c06dbdbbf24a8cd6012
parent17df8dea1f5ea9f69a9872b2674f78c2e92df84c
ALSA: usb-audio: Fix a memory leak bug

BugLink: https://bugs.launchpad.net/bugs/1838576
commit cb5173594d50c72b7bfa14113dfc5084b4d2f726 upstream.

In parse_audio_selector_unit(), the string array 'namelist' is allocated
through kmalloc_array(), and each string pointer in this array, i.e.,
'namelist[]', is allocated through kmalloc() in the following for loop.
Then, a control instance 'kctl' is created by invoking snd_ctl_new1(). If
an error occurs during the creation process, the string array 'namelist',
including all string pointers in the array 'namelist[]', should be freed,
before the error code ENOMEM is returned. However, the current code does
not free 'namelist[]', resulting in memory leaks.

To fix the above issue, free all string pointers 'namelist[]' in a loop.

Signed-off-by: Wenwen Wang <wang6495@umn.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
sound/usb/mixer.c