summaryrefslogtreecommitdiff
path: root/misc/dumpe2fs.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2014-07-05 21:06:29 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-07-05 21:06:48 -0400
commit47fee2ef6a23ae06f680336ffde57caa64604a4c (patch)
treef676e46cb15b8629cf46eca18185d1489395bd67 /misc/dumpe2fs.c
parente7822c1f40281195dbae84a83faf0f57e7e7eb81 (diff)
downloade2fsprogs-47fee2ef6a23ae06f680336ffde57caa64604a4c.tar.gz
e2fsprogs: introduce ext2fs_close_free() helper
Currently there are many uses of ext2fs_close() which might be wrong. First of all ext2fs_close() does not set the ext2_filsys pointer to NULL so the caller is responsible for clearing it, however there are some cases there we do not do it. Second of all very small number of users of ext2fs_close() actually check the return value. If there is a problem in ext2fs_close() it will not even free the ext2_filsys structure, but majority of users expect it to do so. To fix both problems this commit introduces a new helper ext2fs_close_free() which will not only check for the return value and free the ext2_filsys structure if the call to ext2fs_close2() failed, but it will also set the ext2_filsys pointer to NULL. Replace every use of ext2fs_close() in e2fsprogs tools with ext2fs_close_free() - there is no real reason to keep using ext2fs_close(). Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'misc/dumpe2fs.c')
-rw-r--r--misc/dumpe2fs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index d4bde8e5..cc18ad83 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -614,7 +614,7 @@ int main (int argc, char ** argv)
if (fs->super->s_feature_incompat &
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
print_journal_information(fs);
- ext2fs_close(fs);
+ ext2fs_close_free(&fs);
exit(0);
}
if ((fs->super->s_feature_compat &
@@ -623,7 +623,7 @@ int main (int argc, char ** argv)
print_inline_journal_information(fs);
list_bad_blocks(fs, 0);
if (header_only) {
- ext2fs_close (fs);
+ ext2fs_close_free(&fs);
exit (0);
}
retval = ext2fs_read_bitmaps (fs);
@@ -634,7 +634,7 @@ int main (int argc, char ** argv)
error_message(retval));
}
}
- ext2fs_close (fs);
+ ext2fs_close_free(&fs);
remove_error_table(&et_ext2_error_table);
exit (0);
}