diff options
author | Coly Li <[email protected]> | 2023-11-20 13:24:55 +0800 |
---|---|---|
committer | Jens Axboe <[email protected]> | 2023-11-20 09:17:51 -0700 |
commit | 777967e7e9f6f5f3e153abffb562bffaf4430d26 (patch) | |
tree | 5985514cd2600afd675da0d53b3f3a901e82420a | |
parent | baf8fb7e0e5ec54ea0839f0c534f2cdcd79bea9c (diff) |
bcache: check return value from btree_node_alloc_replacement()
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: Coly Li <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Cc: <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r-- | drivers/md/bcache/btree.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index ae5cbb55861f..de8d552201dc 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -1532,6 +1532,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)) { |