]> git.baikalelectronics.ru Git - kernel.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)
committerTakashi Iwai <tiwai@suse.de>
Wed, 29 Jan 2020 20:01:19 +0000 (21:01 +0100)
commit0af359a704a6d0ad5ce0f21269fec2f1f4011f3c
treece3be32aac7d4333c672af1a2af8babd7c47575b
parent45afb9c2b378d2999714f88f651ece0e1daa8094
ALSA: pcm: Fix memory leak at closing a stream without hw_free

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: 631a51d81c95 ("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>
sound/core/pcm_native.c