From: Daniel Rosenberg via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
kernel-team@android.com, Daniel Rosenberg <drosen@google.com>
Subject: [f2fs-dev] [PATCH 2/2] libf2fs: Fix possible memleak with Sparse Files
Date: Fri, 26 Jan 2024 14:18:45 -0800 [thread overview]
Message-ID: <20240126221845.265859-2-drosen@google.com> (raw)
In-Reply-To: <20240126221845.265859-1-drosen@google.com>
If sparse files is set along with multiple devices, we initialize
sparse file data multiple times without freeing the previously allocated
data. This skips the initialization for subsequent devices, as sparse
file mode currently only deals with device 0 anyways.
Signed-off-by: Daniel Rosenberg <drosen@google.com>
---
lib/libf2fs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 2451201..13f2b07 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -974,7 +974,7 @@ int get_device_info(int i)
dev->fd = fd;
- if (c.sparse_mode) {
+ if (c.sparse_mode && i == 0) {
if (f2fs_init_sparse_file()) {
free(stat_buf);
return -1;
@@ -1221,7 +1221,7 @@ int get_device_info(int i)
c.sectors_per_blk = F2FS_BLKSIZE / c.sector_size;
c.total_sectors += dev->total_sectors;
- if (c.sparse_mode && f2fs_init_sparse_file())
+ if (c.sparse_mode && i==0 && f2fs_init_sparse_file())
return -1;
return 0;
}
--
2.43.0.429.g432eaa2c6b-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2024-01-26 22:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 22:18 [f2fs-dev] [PATCH 1/2] libf2fs: Accept Sparse files with non 4K Blocksize Daniel Rosenberg via Linux-f2fs-devel
2024-01-26 22:18 ` Daniel Rosenberg via Linux-f2fs-devel [this message]
2024-01-29 20:14 ` Jaegeuk Kim
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=20240126221845.265859-2-drosen@google.com \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=drosen@google.com \
--cc=jaegeuk@kernel.org \
--cc=kernel-team@android.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