Patch "bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bcache-fix-__bch_btree_node_alloc-to-make-the-failur.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b06c00715f57bfdb88e4123057538fbbdb9d7cdd
Author: Zheng Wang <zyytlz.wz@xxxxxxx>
Date:   Thu Jun 15 20:12:22 2023 +0800

    bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent
    
    [ Upstream commit 80fca8a10b604afad6c14213fdfd816c4eda3ee4 ]
    
    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@xxxxxxxxxxxxxxx
    Signed-off-by: Zheng Wang <zyytlz.wz@xxxxxxx>
    Signed-off-by: Coly Li <colyli@xxxxxxx>
    Link: https://lore.kernel.org/r/20230615121223.22502-6-colyli@xxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 40eea56b9c900..71d670934a07e 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -1125,10 +1125,12 @@ struct btree *__bch_btree_node_alloc(struct cache_set *c, struct btree_op *op,
 				     struct btree *parent)
 {
 	BKEY_PADDED(key) k;
-	struct btree *b = ERR_PTR(-EAGAIN);
+	struct btree *b;
 
 	mutex_lock(&c->bucket_lock);
 retry:
+	/* return ERR_PTR(-EAGAIN) when it fails */
+	b = ERR_PTR(-EAGAIN);
 	if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, wait))
 		goto err;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux