Re: [PATCH] selftests/alsa: Fix memory leak in find_controls error path

From: Takashi Iwai

Date: Sun Jul 05 2026 - 03:40:13 EST


On Sat, 04 Jul 2026 12:57:36 +0200,
Malaya Kumar Rout wrote:
>
> 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@xxxxxxxxx>

Applied now. Thanks.


Takashi