]> www.infradead.org Git - users/dwmw2/linux.git/commit
ALSA: pcm: Fix memory leak at closing a stream without hw_free
authorTakashi Iwai <tiwai@suse.de>
Wed, 29 Jan 2020 19:59:07 +0000 (20:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:36:39 +0000 (04:36 -0800)
commita03dc5ac36ad1a266ee998c9e07da49bce2de1a1
treef89e931c4d57c0b37b8d71860779ef6a98a92c46
parente9d537761faca125f5c9a9250767bfed41252c09
ALSA: pcm: Fix memory leak at closing a stream without hw_free

commit 66f2d19f8116e16898f8d82e28573a384ddc430d upstream.

ALSA PCM core recently introduced a new managed PCM buffer allocation
mode that does allocate / free automatically at hw_params and
hw_free.  However, it overlooked the code path directly calling
hw_free PCM ops at releasing the PCM substream, and it may result in a
memory leak as spotted by syzkaller when no buffer preallocation is
used (e.g. vmalloc buffer).

This patch papers over it with a slight refactoring.  The hw_free ops
call and relevant tasks are unified in a new helper function, and call
it from both places.

Fixes: 0dba808eae26 ("ALSA: pcm: Introduce managed buffer allocation mode")
Reported-by: syzbot+30edd0f34bfcdc548ac4@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200129195907.12197-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/pcm_native.c