[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210618075925.803052-1-cccheng@synology.com>
Date: Fri, 18 Jun 2021 15:59:25 +0800
From: Chung-Chiang Cheng <shepjeng@...il.com>
To: jlbec@...lplan.org, hch@....de, pantelis.antoniou@...sulko.com
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Chung-Chiang Cheng <cccheng@...ology.com>
Subject: [PATCH] configfs: fix memleak in configfs_release_bin_file
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@...ology.com>
---
fs/configfs/file.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index e26060dae70a..cdd23f4a51c8 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -466,9 +466,13 @@ static int configfs_release_bin_file(struct inode *inode, struct file *file)
{
struct configfs_buffer *buffer = file->private_data;
- buffer->read_in_progress = false;
-
- if (buffer->write_in_progress) {
+ if (buffer->read_in_progress) {
+ buffer->read_in_progress = false;
+ vfree(buffer->bin_buffer);
+ buffer->bin_buffer = NULL;
+ buffer->bin_buffer_size = 0;
+ buffer->needs_read_fill = 1;
+ } else if (buffer->write_in_progress) {
struct configfs_fragment *frag = to_frag(file);
buffer->write_in_progress = false;
--
2.25.1
Powered by blists - more mailing lists