Skip to contentSkip to conversation

btrfs: Drop inode if inode root is NULL

PATCH In review [email protected] 2 participants 2 messages Jun 6, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Drop inode if inode root is NULL

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.

---
 fs/btrfs/inode.c | 3 +++
 1 file changed, 3 insertions(+)
fs/btrfs/inode.c +3 -0
index af978f7..17f3064 100644
@@ -8012,6 +8012,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)
Signature · 1 line
1.8.2.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On thu, 06 Jun 2013 18:56:34 +0900, [email protected] wrote:

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.

Quoted 19 lines
---
 fs/btrfs/inode.c | 3 +++
 1 file changed, 3 insertions(+)
fs/btrfs/inode.c +3 -0
index af978f7..17f3064 100644
@@ -8012,6 +8012,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)