Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent

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>

authored by

Zheng Wang and committed by
Jens Axboe
80fca8a1 028ddcac

+3 -1
+3 -1
drivers/md/bcache/btree.c
··· 1090 1090 struct btree *parent) 1091 1091 { 1092 1092 BKEY_PADDED(key) k; 1093 - struct btree *b = ERR_PTR(-EAGAIN); 1093 + struct btree *b; 1094 1094 1095 1095 mutex_lock(&c->bucket_lock); 1096 1096 retry: 1097 + /* return ERR_PTR(-EAGAIN) when it fails */ 1098 + b = ERR_PTR(-EAGAIN); 1097 1099 if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, wait)) 1098 1100 goto err; 1099 1101