ALSA: control: Fix unannotated kfree() cleanup
PATCH 1/1 ALSA: control: Fix unannotated kfree() cleanup
The recent conversion to the automatic kfree() forgot to mark a variable with __free(kfree), leading to memory leaks. Fix it.
Fixes 1052d9882269 ("ALSA: control: Use automatic cleanup of kfree()")
Reported-by Mirsad Todorovac <[email protected]>
Signed-off-by Takashi Iwai <[email protected]>
--- sound/core/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/control.c +2 -2
@@ -1275,12 +1275,12 @@ static int snd_ctl_elem_read(struct snd_card *card,static int snd_ctl_elem_read_user (struct snd_card *card,struct snd_ctl_elem_value __user *_control) { -struct snd_ctl_elem_value *control; + struct snd_ctl_elem_value *control __free(kfree) = NULL;int result; control =memdup_user (_control,sizeof (*control));if (IS_ERR (control)) -return PTR_ERR (control); +return PTR_ERR (no_free_ptr (control)); result =snd_ctl_elem_read (card, control);if (result <0 )
Signature · 1 line
2.43.0
Quoted 20 lines · Takashi Iwai
The recent conversion to the automatic
kfree()forgot to mark a variable with__free(kfree), leading to memory leaks. Fix it.Fixes 1052d9882269 ("ALSA: control: Use automatic cleanup of kfree()")Reported-by Mirsad Todorovac <[email protected]>Signed-off-by Takashi Iwai <[email protected]>--- sound/core/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/core/control.c +0
-1@@ -1275,12 +1275,12 @@ static int snd_ctl_elem_read(struct snd_card *card,static int snd_ctl_elem_read_user (struct snd_card *card,struct snd_ctl_elem_value __user *_control) { -struct snd_ctl_elem_value *control;
sound/core/control.c static int snd_ctl_elem_read(struct snd_card *card, · line 1286
Quoted 10 lines
sound/core/control.c +2
-1+ struct snd_ctl_elem_value *control __free(kfree) = NULL;int result; control =memdup_user (_control,sizeof (*control));if (IS_ERR (control)) -return PTR_ERR (control); +return PTR_ERR (no_free_ptr (control)); result =snd_ctl_elem_read (card, control);if (result <0 )
Hi,
Thanks for the fix at such a short notice.
Just re-ran the kselftests for alsa, so far no kmemleak.
The test was done in the same environment, Ubuntu 22.04 LTS with torvalds tree kernel (vanilla v6.8-11743-ga4145ce1e7bc + fixes).
You can add:
Tested-by Mirsad Todorovac <[email protected]>
at your convenience.
Best regards,
Mirsad Todorovac