btrfs: fix NULL pointer dereference from free_reloc_roots()
authorNaohiro Aota <naohiro.aota@wdc.com>
Fri, 25 Aug 2017 05:15:14 +0000 (14:15 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Oct 2017 07:44:03 +0000 (09:44 +0200)
commitb86b6c226beafc28d5935ebb99590348cb48b633
tree55d7c2d0b4a843ddeae500186e33554c17f324d1
parentbb1e06d281a82c75487fb7ddf25e540b82db4306
btrfs: fix NULL pointer dereference from free_reloc_roots()

commit bb166d7207432d3c7d10c45dc052f12ba3a2121d upstream.

__del_reloc_root should be called before freeing up reloc_root->node.
If not, calling __del_reloc_root() dereference reloc_root->node, causing
the system BUG.

Fixes: 6bdf131fac23 ("Btrfs: don't leak reloc root nodes on error")
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/relocation.c