]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Btrfs: avoid null dereference and leaks when bailing from open_ctree()
authorIlya Dryomov <idryomov@gmail.com>
Tue, 8 Nov 2011 22:08:15 +0000 (00:08 +0200)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:57 +0000 (21:20 -0500)
commit0e11d850b44a16a30da9c271a67facc132db5d74
tree9ddd735e254fb561f87045c3bfeec406cb80603e
parente28b122b0f12333a7f8bc054b1cd11f4a3365492
Btrfs: avoid null dereference and leaks when bailing from open_ctree()

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: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 4d34b2789538befa45a68a191dc12e0886a69f7d)
fs/btrfs/disk-io.c