This is a note to let you know that I've just added the patch titled block: fix module reference leakage from bdev_open_by_dev error path to the 6.8-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: block-fix-module-reference-leakage-from-bdev_open_by.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit d56aef9a83f6b0107076d84f89d617f2747e63cc Author: Yu Kuai <yukuai3@xxxxxxxxxx> Date: Sat Apr 6 17:09:25 2024 +0800 block: fix module reference leakage from bdev_open_by_dev error path [ Upstream commit 9617cd6f24b294552a817f80f5225431ef67b540 ] At the time bdev_may_open() is called, module reference is grabbed already, hence module reference should be released if bdev_may_open() failed. This problem is found by code review. Fixes: ed5cc702d311 ("block: Add config option to not allow writing to mounted devices") Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx> Link: https://lore.kernel.org/r/20240406090930.2252838-22-yukuai1@xxxxxxxxxxxxxxx Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/block/bdev.c b/block/bdev.c index 2b0f97651a0a7..812872cdc0bef 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -873,7 +873,7 @@ struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder, goto abort_claiming; ret = -EBUSY; if (!bdev_may_open(bdev, mode)) - goto abort_claiming; + goto put_module; if (bdev_is_partition(bdev)) ret = blkdev_get_part(bdev, mode); else