]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix off-by-one logic error in btrfs_realloc_node
authorFilipe Manana <fdmanana@suse.com>
Mon, 23 Feb 2015 19:48:52 +0000 (19:48 +0000)
committerChris Mason <clm@fb.com>
Mon, 2 Mar 2015 22:04:45 +0000 (14:04 -0800)
commitacde93478e82735466d305e20f4c71579f28cab0
treea0f3398927bcd6e15a7347f741b186eb85cf3fc1
parentf678fc92a9c6157e65f905ad5c2c288c00cbad4f
Btrfs: fix off-by-one logic error in btrfs_realloc_node

The end_slot variable actually matches the number of pointers in the
node and not the last slot (which is 'nritems - 1'). Therefore in order
to check that the current slot in the for loop doesn't match the last
one, the correct logic is to check if 'i' is less than 'end_slot - 1'
and not 'end_slot - 2'.

Fix this and set end_slot to be 'nritems - 1', as it's less confusing
since the variable name implies it's inclusive rather then exclusive.

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