bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent
authorZheng Wang <zyytlz.wz@163.com>
Thu, 15 Jun 2023 12:12:22 +0000 (20:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:22:10 +0000 (16:22 +0200)
commit7ecea5ce3dc17339c280c75b58ac93d8c8620d9f
treee8edd831bab8e9b3bc8b8073c5b769f172f3f455
parent68118c339c6e1e16ae017bef160dbe28a27ae9c8
bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent

commit 80fca8a10b604afad6c14213fdfd816c4eda3ee4 upstream.

In some specific situations, the return value of __bch_btree_node_alloc
may be NULL. This may lead to a potential NULL pointer dereference in
caller function like a calling chain :
btree_split->bch_btree_node_alloc->__bch_btree_node_alloc.

Fix it by initializing the return value in __bch_btree_node_alloc.

Fixes: cafe56359144 ("bcache: A block layer cache")
Cc: stable@vger.kernel.org
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20230615121223.22502-6-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/bcache/btree.c