Btrfs: handle kzalloc() failure in open_ctree()
authorDan Carpenter <error27@gmail.com>
Sat, 29 May 2010 09:43:07 +0000 (09:43 +0000)
committerChris Mason <chris.mason@oracle.com>
Fri, 11 Jun 2010 19:57:34 +0000 (15:57 -0400)
Unwind and return -ENOMEM if the allocation fails here.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/disk-io.c

index f3b287c22caf2e6855cf89bf780cf0b4b675c902..73895baf6e07383a628e2c912f33a6cb17a8c4f8 100644 (file)
@@ -1941,8 +1941,11 @@ struct btrfs_root *open_ctree(struct super_block *sb,
                     btrfs_level_size(tree_root,
                                      btrfs_super_log_root_level(disk_super));
 
-               log_tree_root = kzalloc(sizeof(struct btrfs_root),
-                                                     GFP_NOFS);
+               log_tree_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS);
+               if (!log_tree_root) {
+                       err = -ENOMEM;
+                       goto fail_trans_kthread;
+               }
 
                __setup_root(nodesize, leafsize, sectorsize, stripesize,
                             log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID);