btrfs: Drop inode if inode root is NULL
authorNaohiro Aota <naota@elisp.net>
Thu, 6 Jun 2013 09:56:34 +0000 (09:56 +0000)
committerChris Mason <chris.mason@fusionio.com>
Sat, 8 Jun 2013 19:07:53 +0000 (15:07 -0400)
There is a path where btrfs_drop_inode() is called with its inode's root
is NULL: In btrfs_new_inode(), when btrfs_set_inode_index() fails,
iput() is called. We should handle this case before taking look at the
root->root_item.

Signed-off-by: Naohiro Aota <naota@elisp.net>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/inode.c

index 23c596cd1b985216bd3d4743540a1f7352920898..c931a4dbd03136ca3de74ab1ad9371b6fbdf23f4 100644 (file)
@@ -8011,6 +8011,9 @@ int btrfs_drop_inode(struct inode *inode)
 {
        struct btrfs_root *root = BTRFS_I(inode)->root;
 
+       if (root == NULL)
+               return 1;
+
        /* the snap/subvol tree is on deleting */
        if (btrfs_root_refs(&root->root_item) == 0 &&
            root != root->fs_info->tree_root)