Btrfs: fix invalid leaf slot access in btrfs_lookup_extent()
authorFilipe Manana <fdmanana@suse.com>
Mon, 27 Oct 2014 10:44:24 +0000 (10:44 +0000)
committerChris Mason <clm@fb.com>
Mon, 27 Oct 2014 20:16:52 +0000 (13:16 -0700)
commit1a4ed8fdca077d2489ec47d548451be69389e926
treefeee30ff76593fde7a28fa24a70dbbcc097c24a3
parent21e7626b12f25770e2975bc7c7b2e1d5b1d58a57
Btrfs: fix invalid leaf slot access in btrfs_lookup_extent()

If we couldn't find our extent item, we accessed the current slot
(path->slots[0]) to check if it corresponds to an equivalent skinny
metadata item. However this slot could be beyond our last item in the
leaf (i.e. path->slots[0] >= btrfs_header_nritems(leaf)), in which case
we shouldn't process it.

Since btrfs_lookup_extent() is only used to find extent items for data
extents, fix this by removing completely the logic that looks up for an
equivalent skinny metadata item, since it can not exist.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/tree-log.c