Re: [PATCH] sound:Fix a memory leak in snd_ctl_elem_add_compat function
From: Takashi Iwai
Date: Sat Mar 23 2024 - 05:31:18 EST
On Sat, 23 Mar 2024 10:27:12 +0100,
LuMingYin wrote:
>
> In the function snd_ctl_elem_add_compat defined in /linux/sound/core/control_compat.c, a pointer named data is declared. This pointer allocates a block of dynamic memory using the kzalloc function at line 354. When the if statement at line 355 returns false, it indicates successful allocation of the dynamic memory area pointed to by data. However, when the if statements at lines 359 or 362 are true, the program will not execute the snd_ctl_elem_add(file, data, replace); operation at line 389 and will return directly. During this process, the dynamic memory area pointed to by data is neither freed nor used, leading to a memory leak bug. This commit fixes the aforementioned memory leak issue.
>
> Signed-off-by: LuMingYin <lumingyindetect@xxxxxxx>
Ditto as another mail, it's automatically freed.
Takashi