]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: control: Fix unannotated kfree() cleanup
authorTakashi Iwai <tiwai@suse.de>
Wed, 20 Mar 2024 06:27:20 +0000 (07:27 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 20 Mar 2024 06:30:48 +0000 (07:30 +0100)
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
Message-ID: <20240320062722.31325-1-tiwai@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/control.c

index 8367fd4853716af763cfe648e5619f6364d2ce1d..fb0c60044f7b3b1a4a8fd478cf68306a9443ef5d 100644 (file)
@@ -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)