Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0016325 authored by Coly Li's avatar Coly Li Committed by Greg Kroah-Hartman
Browse files

bcache: check return value from btree_node_alloc_replacement()



commit 777967e7e9f6f5f3e153abffb562bffaf4430d26 upstream.

In btree_gc_rewrite_node(), pointer 'n' is not checked after it returns
from btree_gc_rewrite_node(). There is potential possibility that 'n' is
a non NULL ERR_PTR(), referencing such error code is not permitted in
following code. Therefore a return value checking is necessary after 'n'
is back from btree_node_alloc_replacement().

Signed-off-by: default avatarColy Li <colyli@suse.de>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Cc:  <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20231120052503.6122-3-colyli@suse.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a658ee79
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1555,6 +1555,8 @@ static int btree_gc_rewrite_node(struct btree *b, struct btree_op *op,
		return 0;

	n = btree_node_alloc_replacement(replace, NULL);
	if (IS_ERR(n))
		return 0;

	/* recheck reserve after allocating replacement node */
	if (btree_check_reserve(b, NULL)) {