From: Takashi Iwai <tiwai@suse.de>
To: Zhao Dongdong <winter91@foxmail.com>
Cc: tiwai@suse.de, joakim.zhang@cixtech.com,
linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
perex@perex.cz, tiwai@suse.com, zhaodongdong@kylinos.cn
Subject: Re: [PATCH] ALSA: hda/core: fix memory leak in snd_hdac_bus_alloc_stream_pages()
Date: Mon, 06 Jul 2026 12:19:22 +0200 [thread overview]
Message-ID: <87pl108lp1.wl-tiwai@suse.de> (raw)
In-Reply-To: <tencent_6643D4C4FD3A63DCC5AEDDEEEEAAB8F12605@qq.com>
On Mon, 06 Jul 2026 10:51:11 +0200,
Zhao Dongdong wrote:
>
> On Mon, 06 Jul 2026 10:11:56 +0200, Takashi Iwai <tiwai@suse.de> wrote:
> >
> > On Mon, 06 Jul 2026 09:41:10 +0200,
> > Zhao Dongdong wrote:
> > >
> > > From: Zhao Dongdong <zhaodongdong@kylinos.cn>
> > >
> > > In snd_hdac_bus_alloc_stream_pages(), there are three memory leak paths:
> > >
> > > 1. If snd_dma_alloc_pages() for the BDL fails at stream i, the
> > > previously allocated BDL DMA buffers (0..i-1) are not freed.
> > >
> > > 2. If snd_dma_alloc_pages() for the position buffer fails, all
> > > previously allocated BDL DMA buffers are leaked.
> > >
> > > 3. If snd_dma_alloc_pages() for the ring buffer fails, all
> > > previously allocated BDL DMA buffers and the position buffer
> > > are leaked.
> > >
> > > Add proper error cleanup: free buffers that have been allocated
> > > before each failure point.
> > >
> > > Fixes: b2660d1ebde1 ("ALSA: hda: Move HD-audio core stuff into sound/hda/core")
> > > Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn>
> >
> > They don't actually leak, as those are supposed to be released by
> > callers (via snd_hdac_bus_free_stream_pages() call at destructor).
> > That is, it's no bug, per se.
> >
> > Of course, it won't be bad to clean up in the function itself, which
> > is more self-contained and safer. But please rephrase the patch
> > subject and description, so that it won't be taken as a security issue
> > incorrectly.
> >
> >
> > thanks,
> >
> > Takashi
>
> Thanks for your review.
> You are right that snd_hdac_bus_alloc_stream_pages and snd_hdac_bus_free_stream_pages
> are paired, so the extra free call is unnecessary, please ignore this patch.
Well, your code change itself is fine as a code hardening, and I'll
happily apply if the patch subject and description are updated.
So, feel free to resubmit with the updated description.
thanks,
Takashi
prev parent reply other threads:[~2026-07-06 10:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 7:41 [PATCH] ALSA: hda/core: fix memory leak in snd_hdac_bus_alloc_stream_pages() Zhao Dongdong
2026-07-06 8:11 ` Takashi Iwai
2026-07-06 8:51 ` Zhao Dongdong
2026-07-06 10:19 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pl108lp1.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=joakim.zhang@cixtech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=winter91@foxmail.com \
--cc=zhaodongdong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox