From abbf95c739cfad7990a67ce73d01f4b6626cb5fc Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 10 Jan 2014 23:04:57 -0500 Subject: [PATCH] tune2fs: add error checking to ext2fs_read_bitmaps() calls Addresses-Coverity-Id: #1153628 Addresses-Coverity-Id: #1153629 Signed-off-by: "Theodore Ts'o" Signed-off-by: Theodore Ts'o --- misc/tune2fs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index c6ec9a5..7e0c3ad 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -727,13 +727,19 @@ static void rewrite_inodes(ext2_filsys fs) static void rewrite_metadata_checksums(ext2_filsys fs) { + errcode_t retval; dgrp_t i; fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS; ext2fs_init_csum_seed(fs); for (i = 0; i < fs->group_desc_count; i++) ext2fs_group_desc_csum_set(fs, i); - ext2fs_read_bitmaps(fs); + retval = ext2fs_read_bitmaps(fs); + if (retval) { + com_err("rewrite_metadata_checksums", retval, + "while reading bitmaps"); + exit(1); + } rewrite_inodes(fs); ext2fs_mark_ib_dirty(fs); ext2fs_mark_bb_dirty(fs); @@ -809,7 +815,12 @@ static void disable_uninit_bg(ext2_filsys fs, __u32 csum_feature_flag) /* Load bitmaps to ensure that the uninit ones get written out */ fs->super->s_feature_ro_compat |= csum_feature_flag; - ext2fs_read_bitmaps(fs); + retval = ext2fs_read_bitmaps(fs); + if (retval) { + com_err("disable_uninit_bg", retval, + "while reading bitmaps"); + return; + } ext2fs_mark_ib_dirty(fs); ext2fs_mark_bb_dirty(fs); fs->super->s_feature_ro_compat &= ~csum_feature_flag; -- 1.8.3.1