[PATCH 6.6 1419/1424] ALSA: control: Fix unannotated kfree() cleanup

From
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date
2026-09-12 15:21:55
Also in
linux-patches
Reply to
Greg Kroah-Hartman, 2026-09-12
6.6-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <redacted>

[ Upstream commit 14d811467f6592aa0e685730e66b5f9123287468 ]

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 <redacted>
Closes: https://lore.kernel.org/r/c1e2ef3c-164f-4840-9b1c-f7ca07ca422a@alu.unizg.hr (local)
Message-ID: [off-list ref]
Signed-off-by: Takashi Iwai <redacted>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 3eca2ff89ab42..784867f29f0b0 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)
-- 
2.53.0


Thread (1,439 messages) 1,439 messages, 12 authors, last reply 12d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help