Skip to content

Commit 9617cd6

Browse files
YuKuai-huaweibrauner
authored andcommitted
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: ed5cc70 ("block: Add config option to not allow writing to mounted devices") Signed-off-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent abe6acf commit 9617cd6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/bdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder,
873873
goto abort_claiming;
874874
ret = -EBUSY;
875875
if (!bdev_may_open(bdev, mode))
876-
goto abort_claiming;
876+
goto put_module;
877877
if (bdev_is_partition(bdev))
878878
ret = blkdev_get_part(bdev, mode);
879879
else

0 commit comments

Comments
 (0)