From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Subject: [PATCH v2 4/4] e2fsck: initialize variable before first use in fast commit replay
Date: Tue, 23 Feb 2021 09:41:56 -0800 [thread overview]
Message-ID: <20210223174156.308507-4-harshads@google.com> (raw)
In-Reply-To: <20210223174156.308507-1-harshads@google.com>
From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Initialize ext2fs_ex variable in ext4_fc_replay_scan() before first
use. Also ensure make ext2fs_decode_extent completely overwrite the
extent structure passed to it as argument to prevent potential future
bugs for the users of the function.
Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
e2fsck/journal.c | 2 +-
lib/ext2fs/extent.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index a67ef745..8e7ba819 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -289,7 +289,7 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh,
struct ext4_fc_tail *tail;
__u8 *start, *end;
struct ext4_fc_head *head;
- struct ext2fs_extent ext2fs_ex;
+ struct ext2fs_extent ext2fs_ex = {0};
state = &ctx->fc_replay_state;
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index 9e611038..b324c7b0 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -1797,7 +1797,7 @@ errcode_t ext2fs_decode_extent(struct ext2fs_extent *to, void *addr, int len)
<< 32);
to->e_lblk = ext2fs_le32_to_cpu(from->ee_block);
to->e_len = ext2fs_le16_to_cpu(from->ee_len);
- to->e_flags |= EXT2_EXTENT_FLAGS_LEAF;
+ to->e_flags = EXT2_EXTENT_FLAGS_LEAF;
if (to->e_len > EXT_INIT_MAX_LEN) {
to->e_len -= EXT_INIT_MAX_LEN;
to->e_flags |= EXT2_EXTENT_FLAGS_UNINIT;
--
2.30.0.617.g56c4b15f3c-goog
next prev parent reply other threads:[~2021-02-23 17:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-23 17:41 [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree Harshad Shirwadkar
2021-02-23 17:41 ` [PATCH v2 2/4] ext2fs: don't ignore return value in ext2fs_count_blocks Harshad Shirwadkar
2021-02-23 17:41 ` [PATCH v2 3/4] e2fsck: add fallthrough comment in fc replay switch case Harshad Shirwadkar
2021-02-23 17:41 ` Harshad Shirwadkar [this message]
2021-02-23 18:06 ` [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree Theodore Ts'o
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=20210223174156.308507-4-harshads@google.com \
--to=harshadshirwadkar@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).