This is a note to let you know that I've just added the patch titled configfs: fix memleak in configfs_release_bin_file to the 5.13-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: configfs-fix-memleak-in-configfs_release_bin_file.patch and it can be found in the queue-5.13 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 846e32fbdf29c7b50a96ae289aa2f10d2fc29e98 Author: Chung-Chiang Cheng <shepjeng@xxxxxxxxx> Date: Fri Jun 18 15:59:25 2021 +0800 configfs: fix memleak in configfs_release_bin_file [ Upstream commit 3c252b087de08d3cb32468b54a158bd7ad0ae2f7 ] When reading binary attributes in progress, buffer->bin_buffer is setup in configfs_read_bin_file() but never freed. Fixes: 03607ace807b4 ("configfs: implement binary attributes") Signed-off-by: Chung-Chiang Cheng <cccheng@xxxxxxxxxxxx> [hch: move the vfree rather than duplicating it] Signed-off-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/configfs/file.c b/fs/configfs/file.c index e26060dae70a..b4b0fbabd62e 100644 --- a/fs/configfs/file.c +++ b/fs/configfs/file.c @@ -480,13 +480,13 @@ static int configfs_release_bin_file(struct inode *inode, struct file *file) buffer->bin_buffer_size); } up_read(&frag->frag_sem); - /* vfree on NULL is safe */ - vfree(buffer->bin_buffer); - buffer->bin_buffer = NULL; - buffer->bin_buffer_size = 0; - buffer->needs_read_fill = 1; } + vfree(buffer->bin_buffer); + buffer->bin_buffer = NULL; + buffer->bin_buffer_size = 0; + buffer->needs_read_fill = 1; + configfs_release(inode, file); return 0; }