btrfs: init csum_list before possible free
authorDan Robertson <dan@dlrobertson.com>
Tue, 19 Feb 2019 02:56:43 +0000 (02:56 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 19:11:22 +0000 (20:11 +0100)
commitebbb48419e8a7933779a5d849d54de47398ba2b1
tree1965b0730caa46ffeb51f23093139a1dd5675bc0
parent88e610ae4c3af07d964ba792313c1ac9d50ec7b6
btrfs: init csum_list before possible free

commit e49be14b8d80e23bb7c53d78c21717a474ade76b upstream.

The scrub_ctx csum_list member must be initialized before scrub_free_ctx
is called. If the csum_list is not initialized beforehand, the
list_empty call in scrub_free_csums will result in a null deref if the
allocation fails in the for loop.

Fixes: a2de733c78fa ("btrfs: scrub")
CC: stable@vger.kernel.org # 3.0+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Dan Robertson <dan@dlrobertson.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/scrub.c