Gui Hecheng
2014-Apr-24 03:39 UTC
[PATCH] 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> --- btrfs-debug-tree.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c index 8ae7270..cb6c106 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); -- 1.8.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html