diff options
author | Gui Hecheng <guihc.fnst@cn.fujitsu.com> | 2014-04-24 11:39:28 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-05-02 17:05:29 +0200 |
commit | 9317400a67ea9c66fe727b21ddf0e7d925dbdaf1 (patch) | |
tree | 6f3daa3b96825e966bd79b17a9f054186ff3314a | |
parent | aa46922c09159d8315a35b81cacf30dcfb9243a5 (diff) |
btrfs-progs: prevent close_root if the root to close is potentially NULL
Originally only if 'block_only' is specified, the 'fs_root == NULL'
will be checked. But if 'block_only' is not specified and close_root
will be called blindly without checking 'fs_root == NULL', which is
unsafe.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r-- | btrfs-debug-tree.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c index 8ae7270d..cb6c1061 100644 --- a/btrfs-debug-tree.c +++ b/btrfs-debug-tree.c @@ -177,13 +177,14 @@ int main(int ac, char **av) fprintf(stderr, "unable to open %s\n", av[optind]); exit(1); } + root = info->fs_root; + if (!root) { + fprintf(stderr, "unable to open %s\n", av[optind]); + exit(1); + } if (block_only) { - if (!root) { - fprintf(stderr, "unable to open %s\n", av[optind]); - exit(1); - } leaf = read_tree_block(root, block_only, root->leafsize, 0); |