mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/1] ALSA: ctxfi: Fix memory leakage when clearing DAO input mappers
@ 2026-10-01 14:45 Harin Lee
  2026-10-01 14:45 ` [PATCH 1/1] " Harin Lee
  0 siblings, 1 reply; 3+ messages in thread
From: Harin Lee @ 2026-10-01 14:45 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai; +Cc: linux-sound, linux-kernel, Harin Lee

I fixed the memory leakage in dao_clear_input() and successfully
tested this patch on an AMD64 system with an OK0010 card and KASAN
enabled.

However, actually I could not find any evidence for why the original
commit mistakenly removed the kfree() calls.

Please feel free to drop this patch when this change looks like it
has not been verified yet.

Harin Lee (1):
  ALSA: ctxfi: Fix memory leakage when clearing DAO input mappers

 sound/pci/ctxfi/ctdaio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] ALSA: ctxfi: Fix memory leakage when clearing DAO input mappers
  2026-10-01 14:45 [PATCH 0/1] ALSA: ctxfi: Fix memory leakage when clearing DAO input mappers Harin Lee
@ 2026-10-01 14:45 ` Harin Lee
  2026-10-03  9:15   ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Harin Lee @ 2026-10-01 14:45 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai; +Cc: linux-sound, linux-kernel, Harin Lee

Commit e576e7843c0d ("ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions")
centralized the DAO input mapper clearing logic in
dao_clear_input(), but omitted the kfree() calls.

It removes the mapper entries from the list and sets their pointers
to NULL without freeing the allocated array. This leaks memory each
time dao_clear_input() is called.

Store the base pointer of the allocation before clearing the mapper
entries and free the array after removing entries from the list.

Fixes: e576e7843c0d ("ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions")
Cc: stable@vger.kernel.org
Signed-off-by: Harin Lee <me@harin.net>
---
 sound/pci/ctxfi/ctdaio.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index 9be70c6862ab..27e502fa493e 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -221,14 +221,18 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input)
 
 static int dao_clear_input(struct dao *dao, unsigned int start, unsigned int end)
 {
+	struct imapper *entry;
 	unsigned int i;
 
-	if (!dao->imappers[start])
+	entry = dao->imappers[start];
+	if (!entry)
 		return 0;
+
 	for (i = start; i < end; i++) {
 		dao->mgr->imap_delete(dao->mgr, dao->imappers[i]);
 		dao->imappers[i] = NULL;
 	}
+	kfree(entry);
 
 	return 0;
 }
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] ALSA: ctxfi: Fix memory leakage when clearing DAO input mappers
  2026-10-01 14:45 ` [PATCH 1/1] " Harin Lee
@ 2026-10-03  9:15   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2026-10-03  9:15 UTC (permalink / raw)
  To: Harin Lee; +Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel

On Thu, 01 Oct 2026 16:45:01 +0200,
Harin Lee wrote:
> 
> Commit e576e7843c0d ("ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions")
> centralized the DAO input mapper clearing logic in
> dao_clear_input(), but omitted the kfree() calls.
> 
> It removes the mapper entries from the list and sets their pointers
> to NULL without freeing the allocated array. This leaks memory each
> time dao_clear_input() is called.
> 
> Store the base pointer of the allocation before clearing the mapper
> entries and free the array after removing entries from the list.
> 
> Fixes: e576e7843c0d ("ALSA: ctxfi: Simplify dao_clear_{left,right}_input() functions")
> Cc: stable@vger.kernel.org
> Signed-off-by: Harin Lee <me@harin.net>

Applied now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-03  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 14:45 [PATCH 0/1] ALSA: ctxfi: Fix memory leakage when clearing DAO input mappers Harin Lee
2026-10-01 14:45 ` [PATCH 1/1] " Harin Lee
2026-10-03  9:15   ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®