mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-23 22:53:35 +00:00
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>
This commit is contained in:
parent
aa46922c09
commit
9317400a67
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user