提交 655b09fe 编写于 作者: J Josef Bacik

Btrfs: make sure roots are assigned before freeing their nodes

If we fail to load the chunk tree we'll call free_root_pointers, except we may
not have assigned the roots for the dev_root/extent_root/csum_root yet, so we
could NULL pointer deref at this point.  Just add checks to make sure these
roots are set to keep us from panicing.  Thanks,
Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
上级 3a6cad90
...@@ -1987,30 +1987,33 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root) ...@@ -1987,30 +1987,33 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root)
{ {
free_extent_buffer(info->tree_root->node); free_extent_buffer(info->tree_root->node);
free_extent_buffer(info->tree_root->commit_root); free_extent_buffer(info->tree_root->commit_root);
free_extent_buffer(info->dev_root->node);
free_extent_buffer(info->dev_root->commit_root);
free_extent_buffer(info->extent_root->node);
free_extent_buffer(info->extent_root->commit_root);
free_extent_buffer(info->csum_root->node);
free_extent_buffer(info->csum_root->commit_root);
if (info->quota_root) {
free_extent_buffer(info->quota_root->node);
free_extent_buffer(info->quota_root->commit_root);
}
info->tree_root->node = NULL; info->tree_root->node = NULL;
info->tree_root->commit_root = NULL; info->tree_root->commit_root = NULL;
info->dev_root->node = NULL;
info->dev_root->commit_root = NULL; if (info->dev_root) {
info->extent_root->node = NULL; free_extent_buffer(info->dev_root->node);
info->extent_root->commit_root = NULL; free_extent_buffer(info->dev_root->commit_root);
info->csum_root->node = NULL; info->dev_root->node = NULL;
info->csum_root->commit_root = NULL; info->dev_root->commit_root = NULL;
}
if (info->extent_root) {
free_extent_buffer(info->extent_root->node);
free_extent_buffer(info->extent_root->commit_root);
info->extent_root->node = NULL;
info->extent_root->commit_root = NULL;
}
if (info->csum_root) {
free_extent_buffer(info->csum_root->node);
free_extent_buffer(info->csum_root->commit_root);
info->csum_root->node = NULL;
info->csum_root->commit_root = NULL;
}
if (info->quota_root) { if (info->quota_root) {
free_extent_buffer(info->quota_root->node);
free_extent_buffer(info->quota_root->commit_root);
info->quota_root->node = NULL; info->quota_root->node = NULL;
info->quota_root->commit_root = NULL; info->quota_root->commit_root = NULL;
} }
if (chunk_root) { if (chunk_root) {
free_extent_buffer(info->chunk_root->node); free_extent_buffer(info->chunk_root->node);
free_extent_buffer(info->chunk_root->commit_root); free_extent_buffer(info->chunk_root->commit_root);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册