]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/alsa: Fix memory leak in find_controls error path
authorMalaya Kumar Rout <malayarout91@gmail.com>
Sat, 4 Jul 2026 10:57:36 +0000 (16:27 +0530)
committerTakashi Iwai <tiwai@suse.de>
Sun, 5 Jul 2026 07:36:41 +0000 (09:36 +0200)
commitcb89f0c1aed02eb233c4271f76f830b37e222ff6
tree98352e68ac592990f4eef31763553dad80f3eeaf
parentb28d3d0841a6083f82dfa9fe940afcd748f2a1e2
selftests/alsa: Fix memory leak in find_controls error path

In find_controls(), card_data is allocated with malloc() but when
snd_ctl_open_lconf() fails, the code jumps to next_card without
freeing the allocated memory. This results in a memory leak for
each card where snd_ctl_open_lconf() fails.

Add free(card_data) before goto next_card to ensure proper cleanup
of the allocated memory in the error path.

Fixes: 5aaf9efffc57 ("kselftest: alsa: Add simplistic test for ALSA mixer controls kselftest")
Signed-off-by: Malaya Kumar Rout <malayarout91@gmail.com>
Link: https://patch.msgid.link/20260704105736.94874-1-malayarout91@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
tools/testing/selftests/alsa/mixer-test.c