From: Eric Sandeen Date: Thu, 29 Jan 2009 22:46:28 +0000 (-0500) Subject: debugfs: fix segfault on "stat" command with no open fs X-Git-Tag: v1.41.5~48 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=eefa4d950cf4da9a835812fe44fb7973ec147cbf;p=tools%2Fe2fsprogs.git debugfs: fix segfault on "stat" command with no open fs This is a regression from commit 8fdf29117f922419bd5b3f741e5d554b1d5b8893, which attempts to access current_fs via a feature check before we check that it's open. Just moving the feature check below the open check should fix it. Reported-by: Andrew Hecox Signed-off-by: Eric Sandeen Signed-off-by: Theodore Ts'o --- diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 8b0965e..95781d9 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -291,9 +291,6 @@ void do_show_super_stats(int argc, char *argv[]) int c, header_only = 0; int numdirs = 0, first, gdt_csum; - gdt_csum = EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super, - EXT4_FEATURE_RO_COMPAT_GDT_CSUM); - reset_getopt(); while ((c = getopt (argc, argv, "h")) != EOF) { switch (c) { @@ -321,6 +318,8 @@ void do_show_super_stats(int argc, char *argv[]) return; } + gdt_csum = EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super, + EXT4_FEATURE_RO_COMPAT_GDT_CSUM); gdp = ¤t_fs->group_desc[0]; for (i = 0; i < current_fs->group_desc_count; i++, gdp++) { fprintf(out, " Group %2d: block bitmap at %u, "