public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daeho Jeong <daeho43@gmail.com>
To: linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>
Subject: [PATCH] f2fs-tools: initialize allocated node area
Date: Fri, 13 Oct 2023 15:24:52 -0700	[thread overview]
Message-ID: <20231013222453.240961-1-daeho43@gmail.com> (raw)

From: Daeho Jeong <daehojeong@google.com>

Need to initialize allocated node areas after memory allocation.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 fsck/node.c       | 1 +
 include/f2fs_fs.h | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/fsck/node.c b/fsck/node.c
index 3761470..6508340 100644
--- a/fsck/node.c
+++ b/fsck/node.c
@@ -127,6 +127,7 @@ block_t new_node_block(struct f2fs_sb_info *sbi,
 
 	node_blk = calloc(BLOCK_SZ, 1);
 	ASSERT(node_blk);
+	memset(node_blk, 0, BLOCK_SZ);
 
 	F2FS_NODE_FOOTER(node_blk)->nid = cpu_to_le32(dn->nid);
 	F2FS_NODE_FOOTER(node_blk)->ino = F2FS_NODE_FOOTER(f2fs_inode)->ino;
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 3c7451c..7e22278 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1826,6 +1826,8 @@ static inline void show_version(const char *prog)
 static inline void f2fs_init_inode(struct f2fs_super_block *sb,
 		struct f2fs_node *raw_node, nid_t ino, time_t mtime, mode_t mode)
 {
+	memset(raw_node, 0, F2FS_BLKSIZE);
+
 	F2FS_NODE_FOOTER(raw_node)->nid = cpu_to_le32(ino);
 	F2FS_NODE_FOOTER(raw_node)->ino = cpu_to_le32(ino);
 	F2FS_NODE_FOOTER(raw_node)->cp_ver = cpu_to_le64(1);
-- 
2.42.0.655.g421f12c284-goog


             reply	other threads:[~2023-10-13 22:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13 22:24 Daeho Jeong [this message]
2023-10-16  6:33 ` [f2fs-dev] [PATCH] f2fs-tools: initialize allocated node area Chao Yu
2023-10-16 15:25   ` Daeho Jeong

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=20231013222453.240961-1-daeho43@gmail.com \
    --to=daeho43@gmail.com \
    --cc=daehojeong@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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