aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-05-17 14:06:51 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-05-17 21:40:38 -0400
commit655b09fe540b73edeaabfb4c2d700be51a1f8bce (patch)
treeee5239ddbadcd4aed7266f61653e28e990bb2978
parent3a6cad9009c85e29e83aafc8ac00b1dd5067fc5f (diff)
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: Josef Bacik <jbacik@fusionio.com>
-rw-r--r--fs/btrfs/disk-io.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1b03f8393a69..4bdb0528688a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1987,30 +1987,33 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root)
1987{ 1987{
1988 free_extent_buffer(info->tree_root->node); 1988 free_extent_buffer(info->tree_root->node);
1989 free_extent_buffer(info->tree_root->commit_root); 1989 free_extent_buffer(info->tree_root->commit_root);
1990 free_extent_buffer(info->dev_root->node);
1991 free_extent_buffer(info->dev_root->commit_root);
1992 free_extent_buffer(info->extent_root->node);
1993 free_extent_buffer(info->extent_root->commit_root);
1994 free_extent_buffer(info->csum_root->node);
1995 free_extent_buffer(info->csum_root->commit_root);
1996 if (info->quota_root) {
1997 free_extent_buffer(info->quota_root->node);
1998 free_extent_buffer(info->quota_root->commit_root);
1999 }
2000
2001 info->tree_root->node = NULL; 1990 info->tree_root->node = NULL;
2002 info->tree_root->commit_root = NULL; 1991 info->tree_root->commit_root = NULL;
2003 info->dev_root->node = NULL; 1992
2004 info->dev_root->commit_root = NULL; 1993 if (info->dev_root) {
2005 info->extent_root->node = NULL; 1994 free_extent_buffer(info->dev_root->node);
2006 info->extent_root->commit_root = NULL; 1995 free_extent_buffer(info->dev_root->commit_root);
2007 info->csum_root->node = NULL; 1996 info->dev_root->node = NULL;
2008 info->csum_root->commit_root = NULL; 1997 info->dev_root->commit_root = NULL;
1998 }
1999 if (info->extent_root) {
2000 free_extent_buffer(info->extent_root->node);
2001 free_extent_buffer(info->extent_root->commit_root);
2002 info->extent_root->node = NULL;
2003 info->extent_root->commit_root = NULL;
2004 }
2005 if (info->csum_root) {
2006 free_extent_buffer(info->csum_root->node);
2007 free_extent_buffer(info->csum_root->commit_root);
2008 info->csum_root->node = NULL;
2009 info->csum_root->commit_root = NULL;
2010 }
2009 if (info->quota_root) { 2011 if (info->quota_root) {
2012 free_extent_buffer(info->quota_root->node);
2013 free_extent_buffer(info->quota_root->commit_root);
2010 info->quota_root->node = NULL; 2014 info->quota_root->node = NULL;
2011 info->quota_root->commit_root = NULL; 2015 info->quota_root->commit_root = NULL;
2012 } 2016 }
2013
2014 if (chunk_root) { 2017 if (chunk_root) {
2015 free_extent_buffer(info->chunk_root->node); 2018 free_extent_buffer(info->chunk_root->node);
2016 free_extent_buffer(info->chunk_root->commit_root); 2019 free_extent_buffer(info->chunk_root->commit_root);