This is a note to let you know that I've just added the patch titled drivers/block/null_blk/main: Fix a double free in null_init. to the 5.10-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: drivers-block-null_blk-main-fix-a-double-free-in-nul.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 749ce6bf5999221983f06ff7a6024617bf007f2a Author: Lv Yunlong <lyl2019@xxxxxxxxxxxxxxxx> Date: Mon Apr 26 07:32:29 2021 -0700 drivers/block/null_blk/main: Fix a double free in null_init. [ Upstream commit 72ce11ddfa4e9e1879103581a60b7e34547eaa0a ] In null_init, null_add_dev(dev) is called. In null_add_dev, it calls null_free_zoned_dev(dev) to free dev->zones via kvfree(dev->zones) in out_cleanup_zone branch and returns err. Then null_init accept the err code and then calls null_free_dev(dev). But in null_free_dev(dev), dev->zones is freed again by null_free_zoned_dev(). My patch set dev->zones to NULL in null_free_zoned_dev() after kvfree(dev->zones) is called, to avoid the double free. Fixes: 2984c8684f962 ("nullb: factor disk parameters") Signed-off-by: Lv Yunlong <lyl2019@xxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20210426143229.7374-1-lyl2019@xxxxxxxxxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c index 172f720b8d63..f5df82c26c16 100644 --- a/drivers/block/null_blk_zoned.c +++ b/drivers/block/null_blk_zoned.c @@ -149,6 +149,7 @@ void null_free_zoned_dev(struct nullb_device *dev) { bitmap_free(dev->zone_locks); kvfree(dev->zones); + dev->zones = NULL; } static inline void null_lock_zone(struct nullb_device *dev, unsigned int zno)