mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	Btrfs: open_ctree() error handling can oops on fs_info
a bug in open_ctree:
struct btrfs_root *open_ctree(..)
{
....
	if (!extent_root || !tree_root || !fs_info ||
	    !chunk_root || !dev_root || !csum_root) {
		err = -ENOMEM;
		goto fail;
//When code flow goes to "fail", fs_info may be NULL or uninitialized.
	}
....
fail:
	btrfs_close_devices(fs_info->fs_devices);// !
	btrfs_mapping_tree_free(&fs_info->mapping_tree);// !
	kfree(extent_root);
	kfree(tree_root);
	bdi_destroy(&fs_info->bdi);// !
...
)
Signed-off-by: Qinghuang Feng <qhfeng.kernel@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
			
			
This commit is contained in:
		
							parent
							
								
									86288a198d
								
							
						
					
					
						commit
						7e6628544a
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -1823,13 +1823,14 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 | 
			
		|||
fail_iput:
 | 
			
		||||
	invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
 | 
			
		||||
	iput(fs_info->btree_inode);
 | 
			
		||||
fail:
 | 
			
		||||
 | 
			
		||||
	btrfs_close_devices(fs_info->fs_devices);
 | 
			
		||||
	btrfs_mapping_tree_free(&fs_info->mapping_tree);
 | 
			
		||||
	bdi_destroy(&fs_info->bdi);
 | 
			
		||||
 | 
			
		||||
fail:
 | 
			
		||||
	kfree(extent_root);
 | 
			
		||||
	kfree(tree_root);
 | 
			
		||||
	bdi_destroy(&fs_info->bdi);
 | 
			
		||||
	kfree(fs_info);
 | 
			
		||||
	kfree(chunk_root);
 | 
			
		||||
	kfree(dev_root);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue