e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree
PATCH v2 1/4 e2fsck: don't ignore return values in e2fsck_rewrite_extent_tree
From: Harshad Shirwadkar <[email protected]>
Don't ignore return values of library function calls in e2fsck_rewrite_extent_tree.
--- e2fsck/extents.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
e2fsck/extents.c +9 -7
@@ -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)
Signature · 1 line
2.30.0.617.g56c4b15f3c-goog
PATCH v2 2/4 ext2fs: don't ignore return value in ext2fs_count_blocks
From: Harshad Shirwadkar <[email protected]>
Don't ignore return value of ext2fs_get_array() in ext2fs_count_blocks().
--- lib/ext2fs/extent.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
lib/ext2fs/extent.c +5 -2
@@ -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 ) {
Signature · 1 line
2.30.0.617.g56c4b15f3c-goog
PATCH v2 3/4 e2fsck: add fallthrough comment in fc replay switch case
In reply to Harshad ShirwadkarFrom: Harshad Shirwadkar <[email protected]>
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.
--- e2fsck/journal.c | 1 + 1 file changed, 1 insertion(+)
e2fsck/journal.c +1 -0
@@ -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 :
Signature · 1 line
2.30.0.617.g56c4b15f3c-goog
PATCH v2 4/4 e2fsck: initialize variable before first use in fast commit replay
In reply to Harshad ShirwadkarFrom: Harshad Shirwadkar <[email protected]>
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.
--- e2fsck/journal.c | 2 +- lib/ext2fs/extent.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
e2fsck/journal.c +1 -1
@@ -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;
lib/ext2fs/extent.c +1 -1
@@ -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 ;
Signature · 1 line
2.30.0.617.g56c4b15f3c-goog
Quoted 6 lines · Harshad Shirwadkar
From: Harshad Shirwadkar <[email protected]>
Don't ignore return values of library function calls in
e2fsck_rewrite_extent_tree.Signed-off-by Harshad Shirwadkar <[email protected]>
Thanks, I've applied this patch series.
- Ted