• Ilya Dryomov's avatar
    Btrfs: avoid null dereference and leaks when bailing from open_ctree() · 4d34b278
    Ilya Dryomov authored
    Fix bugs introduced by 6c41761f.  Firstly, after failing to allocate any
    of the tree roots (first 'goto fail' in open_ctree()) we would
    dereference a NULL fs_info pointer in free_fs_info().  Secondly, after
    failures from init_srcu_struct(), setup_bdi() and new_inode() we would
    leak all earlier allocated roots: fs_info fields haven't been
    initialized yet so free_fs_info() is rendered useless.
    
    Fix this by initializing fs_info pointer and fs_info fields before any
    allocations happen.
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    4d34b278
disk-io.c 93.8 KB