Message ID | 20240320062722.31325-1-tiwai@suse.de (mailing list archive) |
---|---|
State | Accepted |
Commit | 14d811467f6592aa0e685730e66b5f9123287468 |
Headers | show |
Series | ALSA: control: Fix unannotated kfree() cleanup | expand |
On 3/20/24 07:27, Takashi Iwai wrote: > 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 <mirsad.todorovac@alu.unizg.hr> > Closes: https://lore.kernel.org/r/c1e2ef3c-164f-4840-9b1c-f7ca07ca422a@alu.unizg.hr > Signed-off-by: Takashi Iwai <tiwai@suse.de> > --- > sound/core/control.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sound/core/control.c b/sound/core/control.c > index 8367fd485371..fb0c60044f7b 100644 > --- a/sound/core/control.c > +++ b/sound/core/control.c > @@ -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) 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 <mirsad.todorovac@alu.unizg.hr> at your convenience. Best regards, Mirsad Todorovac
diff --git a/sound/core/control.c b/sound/core/control.c index 8367fd485371..fb0c60044f7b 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -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)
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 <mirsad.todorovac@alu.unizg.hr> Closes: https://lore.kernel.org/r/c1e2ef3c-164f-4840-9b1c-f7ca07ca422a@alu.unizg.hr Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/core/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)