diff mbox series

[v4,06/10] bdev: reset first_open when looping in __blkget_dev

Message ID 3d315cdc2847db0942168ef3df920acb55b9e5fd.1574355709.git.msuchanek@suse.de (mailing list archive)
State Superseded
Headers show
Series Fix cdrom autoclose | expand

Commit Message

Michal Suchanek Nov. 21, 2019, 5:13 p.m. UTC
It is not clear that no other thread cannot open the block device when
__blkget_dev drops it and loop to restart label. Reset first_open to
false when looping.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 fs/block_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9c073dbdc1b0..a3083fbada8b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1525,7 +1525,7 @@  static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 	int ret;
 	int partno;
 	int perm = 0;
-	bool first_open = false;
+	bool first_open;
 
 	if (mode & FMODE_READ)
 		perm |= MAY_READ;
@@ -1545,6 +1545,7 @@  static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
  restart:
 
 	ret = -ENXIO;
+	first_open = false;
 	disk = bdev_get_gendisk(bdev, &partno);
 	if (!disk)
 		goto out;