]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Prevent possible ERR_PTR() dereference
authorNikolay Borisov <nborisov@suse.com>
Tue, 11 Jul 2017 13:55:51 +0000 (16:55 +0300)
committerDavid Sterba <dsterba@suse.com>
Wed, 16 Aug 2017 14:12:02 +0000 (16:12 +0200)
commit8ac72abbd6f8b467e7cdd1a76d0e35050ccf894f
treead1f99857cd90e5ba7372d0113d20b8cc3f330f7
parent184ca2e7aedee183956d73cf253f2c03aa39a595
btrfs: Prevent possible ERR_PTR() dereference

In btrfs_full_stripe_len/btrfs_is_parity_mirror we have similar code which
gets the chunk map for a particular range via get_chunk_map. However,
get_chunk_map can return an ERR_PTR value and while the 2 callers do catch
this with a WARN_ON they then proceed to indiscriminately dereference the
extent map. This of course leads to a crash. Fix the offenders by making the
dereference conditional on IS_ERR.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c