All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree
@ 2021-02-23 17:41 Harshad Shirwadkar
  2021-02-23 17:41 ` [PATCH v2 2/4] ext2fs: don't ignore return value in ext2fs_count_blocks Harshad Shirwadkar
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Harshad Shirwadkar @ 2021-02-23 17:41 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, Harshad Shirwadkar

From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

Don't ignore return values of library function calls in
e2fsck_rewrite_extent_tree.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 e2fsck/extents.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/e2fsck/extents.c b/e2fsck/extents.c
index 600dbc97..018737af 100644
--- a/e2fsck/extents.c
+++ b/e2fsck/extents.c
@@ -290,8 +290,10 @@ errcode_t e2fsck_rewrite_extent_tree(e2fsck_t ctx, struct extent_list *list)
 	errcode_t err;
 
 	memset(&inode, 0, sizeof(inode));
-	ext2fs_read_inode_full(ctx->fs, list->ino, EXT2_INODE(&inode),
-				sizeof(inode));
+	err = ext2fs_read_inode_full(ctx->fs, list->ino, EXT2_INODE(&inode),
+				     sizeof(inode));
+	if (err)
+		return err;
 
 	/* Skip deleted inodes and inline data files */
 	if (inode.i_flags & EXT4_INLINE_DATA_FL)
@@ -305,11 +307,11 @@ errcode_t e2fsck_rewrite_extent_tree(e2fsck_t ctx, struct extent_list *list)
 				  &blk_count);
 	if (err)
 		return err;
-	ext2fs_iblk_set(ctx->fs, EXT2_INODE(&inode), blk_count);
-	ext2fs_write_inode_full(ctx->fs, list->ino, EXT2_INODE(&inode),
-		sizeof(inode));
-
-	return 0;
+	err = ext2fs_iblk_set(ctx->fs, EXT2_INODE(&inode), blk_count);
+	if (err)
+		return err;
+	return ext2fs_write_inode_full(ctx->fs, list->ino, EXT2_INODE(&inode),
+				       sizeof(inode));
 }
 
 errcode_t e2fsck_read_extents(e2fsck_t ctx, struct extent_list *extents)
-- 
2.30.0.617.g56c4b15f3c-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/4] ext2fs: don't ignore return value in ext2fs_count_blocks
  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 ` Harshad Shirwadkar
  2021-02-23 17:41 ` [PATCH v2 3/4] e2fsck: add fallthrough comment in fc replay switch case Harshad Shirwadkar
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Harshad Shirwadkar @ 2021-02-23 17:41 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, Harshad Shirwadkar

From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

Don't ignore return value of ext2fs_get_array() in
ext2fs_count_blocks().

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 lib/ext2fs/extent.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index 1a87e68b..9e611038 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -1824,8 +1824,11 @@ errcode_t ext2fs_count_blocks(ext2_filsys fs, ext2_ino_t ino,
 	if (errcode)
 		goto out;
 
-	ext2fs_get_array(handle->max_depth, sizeof(blk64_t),
-				&intermediate_nodes);
+	errcode = ext2fs_get_array(handle->max_depth, sizeof(blk64_t),
+				   &intermediate_nodes);
+	if (errcode)
+		goto out;
+
 	blkcount = handle->level;
 	while (!errcode) {
 		if (extent.e_flags & EXT2_EXTENT_FLAGS_LEAF) {
-- 
2.30.0.617.g56c4b15f3c-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/4] e2fsck: add fallthrough comment in fc replay switch case
  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 ` Harshad Shirwadkar
  2021-02-23 17:41 ` [PATCH v2 4/4] e2fsck: initialize variable before first use in fast commit replay Harshad Shirwadkar
  2021-02-23 18:06 ` [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree Theodore Ts'o
  3 siblings, 0 replies; 5+ messages in thread
From: Harshad Shirwadkar @ 2021-02-23 17:41 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, Harshad Shirwadkar

From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

During fast commit replay scan phase, in ext4_fc_replay_scan(), we
want to fallthrough in switch case for EXT4_FC_TAG_ADD_RANGE case. Add
a comment for that.

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
---
 e2fsck/journal.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 2708942a..a67ef745 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -325,6 +325,7 @@ static int ext4_fc_replay_scan(journal_t *j, struct buffer_head *bh,
 				ret = JBD2_FC_REPLAY_STOP;
 			else
 				ret = JBD2_FC_REPLAY_CONTINUE;
+			/* fallthrough */
 		case EXT4_FC_TAG_DEL_RANGE:
 		case EXT4_FC_TAG_LINK:
 		case EXT4_FC_TAG_UNLINK:
-- 
2.30.0.617.g56c4b15f3c-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 4/4] e2fsck: initialize variable before first use in fast commit replay
  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
  2021-02-23 18:06 ` [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree Theodore Ts'o
  3 siblings, 0 replies; 5+ messages in thread
From: Harshad Shirwadkar @ 2021-02-23 17:41 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, Harshad Shirwadkar

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree
  2021-02-23 17:41 [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree Harshad Shirwadkar
                   ` (2 preceding siblings ...)
  2021-02-23 17:41 ` [PATCH v2 4/4] e2fsck: initialize variable before first use in fast commit replay Harshad Shirwadkar
@ 2021-02-23 18:06 ` Theodore Ts'o
  3 siblings, 0 replies; 5+ messages in thread
From: Theodore Ts'o @ 2021-02-23 18:06 UTC (permalink / raw)
  To: Harshad Shirwadkar; +Cc: linux-ext4

On Tue, Feb 23, 2021 at 09:41:53AM -0800, Harshad Shirwadkar wrote:
> From: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
> 
> Don't ignore return values of library function calls in
> e2fsck_rewrite_extent_tree.
> 
> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

Thanks, I've applied this patch series.

						- Ted

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-23 18:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 4/4] e2fsck: initialize variable before first use in fast commit replay Harshad Shirwadkar
2021-02-23 18:06 ` [PATCH v2 1/4] e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.