From: Takashi Iwai <tiwai@suse.de>
To: Zhao Dongdong <winter91@foxmail.com>
Cc: perex@perex.cz, tiwai@suse.com, joakim.zhang@cixtech.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhao Dongdong <zhaodongdong@kylinos.cn>
Subject: Re: [PATCH] ALSA: hda/core: fix memory leak in snd_hdac_bus_alloc_stream_pages()
Date: Mon, 06 Jul 2026 10:11:56 +0200 [thread overview]
Message-ID: <878q7o5ygj.wl-tiwai@suse.de> (raw)
In-Reply-To: <tencent_B59DA88C3B51869ACB72BBD81D6171C24D06@qq.com>
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
next prev parent reply other threads:[~2026-07-06 8:12 UTC|newest]
Thread overview: 5+ 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 [this message]
2026-07-06 8:51 ` Zhao Dongdong
2026-07-06 10:19 ` Takashi Iwai
2026-07-07 1:56 ` Zhao Dongdong
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=878q7o5ygj.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