]> git.baikalelectronics.ru Git - kernel.git/commit
dm btree: fix order of block initialization in btree_split_beneath
authorZhangXiaoxu <zhangxiaoxu5@huawei.com>
Sat, 17 Aug 2019 05:32:40 +0000 (13:32 +0800)
committerMike Snitzer <snitzer@redhat.com>
Thu, 22 Aug 2019 20:11:23 +0000 (16:11 -0400)
commitb262d59ffe0e395fb655f337dfb61725be2f9a34
treee7d3f420754a270eb34f67d6af0187909821aba9
parentfaf224c732341924e2e499a6db7e7ee0c0382c9c
dm btree: fix order of block initialization in btree_split_beneath

When btree_split_beneath() splits a node to two new children, it will
allocate two blocks: left and right.  If right block's allocation
failed, the left block will be unlocked and marked dirty.  If this
happened, the left block'ss content is zero, because it wasn't
initialized with the btree struct before the attempot to allocate the
right block.  Upon return, when flushing the left block to disk, the
validator will fail when check this block.  Then a BUG_ON is raised.

Fix this by completely initializing the left block before allocating and
initializing the right block.

Fixes: 4e98028405ea0 ("dm btree: fix leak of bufio-backed block in btree_split_beneath error path")
Cc: stable@vger.kernel.org
Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/persistent-data/dm-btree.c