summaryrefslogtreecommitdiffstats
path: root/block/bdev.c
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2024-04-06 11:09:25 +0200
committerChristian Brauner <brauner@kernel.org>2024-04-11 11:14:36 +0200
commit9617cd6f24b294552a817f80f5225431ef67b540 (patch)
tree6edfc794ad4e0c47ef1836516c188cdb79d9d55a /block/bdev.c
parentfs: Return ENOTTY directly if FS_IOC_GETUUID or FS_IOC_GETFSSYSFSPATH fail (diff)
downloadlinux-9617cd6f24b294552a817f80f5225431ef67b540.tar.xz
linux-9617cd6f24b294552a817f80f5225431ef67b540.zip
block: fix module reference leakage from bdev_open_by_dev error path
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@huawei.com> Link: https://lore.kernel.org/r/20240406090930.2252838-22-yukuai1@huaweicloud.com Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'block/bdev.c')
-rw-r--r--block/bdev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/bdev.c b/block/bdev.c
index b8e32d933a63..3caf24e66559 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -873,7 +873,7 @@ int bdev_open(struct block_device *bdev, 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