From: Chung-Chiang Cheng <shepjeng@gmail.com>
To: jlbec@evilplan.org, hch@lst.de, pantelis.antoniou@konsulko.com
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Chung-Chiang Cheng <cccheng@synology.com>
Subject: [PATCH] configfs: fix memleak in configfs_release_bin_file
Date: Fri, 18 Jun 2021 15:59:25 +0800 [thread overview]
Message-ID: <20210618075925.803052-1-cccheng@synology.com> (raw)
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@synology.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
next reply other threads:[~2021-06-18 7:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 7:59 Chung-Chiang Cheng [this message]
2021-06-22 6:04 ` [PATCH] configfs: fix memleak in configfs_release_bin_file Christoph Hellwig
2021-06-22 7:40 ` Chung-Chiang Cheng
2021-06-22 8:04 ` Christoph Hellwig
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=20210618075925.803052-1-cccheng@synology.com \
--to=shepjeng@gmail.com \
--cc=cccheng@synology.com \
--cc=hch@lst.de \
--cc=jlbec@evilplan.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pantelis.antoniou@konsulko.com \
/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;
as well as URLs for NNTP newsgroup(s).