diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-03-28 10:27:46 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-04-23 18:56:26 +0200 |
commit | 82ecc3670856efc9e9faa62bab75dd216ec2be94 (patch) | |
tree | f54b366956e1f65a11eda93b26f946b037f88e58 /cmds-check.c | |
parent | 1ed8193d19413dfa12ad069fe3458864e144297c (diff) |
Btrfs-progs: fix segfault in fsck if the chunk tree is bogus
I made open_ctree fail if the chunk tree couldn't be open, which means that fsck
now segfaults if it can't open the chunk tree. So fix fsck to check the fs_info
we get back from open_ctree_fsinfo to make sure it's valid and exit if it's not
instead of segfaulting. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r-- | cmds-check.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/cmds-check.c b/cmds-check.c index d39e7972..4eb2ef9b 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -3860,8 +3860,10 @@ int cmd_check(int argc, char **argv) } info = open_ctree_fs_info(argv[optind], bytenr, rw, 1); - if (info == NULL) - return 1; + if (!info) { + fprintf(stderr, "Couldn't open file system\n"); + return -EIO; + } uuid_unparse(info->super_copy->fsid, uuidbuf); printf("Checking filesystem on %s\nUUID: %s\n", argv[optind], uuidbuf); |