[PATCH] floppy: fail the open when floppy_revalidate() fails
From: Denis Efremov (Oracle)
Date: Tue Oct 06 2026 - 06:03:51 EST
floppy_open() ignores what floppy_revalidate() returns. If lock_fdc() is
interrupted, or __floppy_read_block_0() can't allocate its page, the open
can succeed without the disk check.
Commit a0c80efe5956 ("floppy: fix lock_fdc() signal handling") made
floppy_revalidate() return -EINTR instead of going on without the FDC
lock, but the error was dropped. Return the error instead.
Fixes: 4a6f3d480edc ("floppy: use bdev_check_media_change")
Signed-off-by: Denis Efremov (Oracle) <efremov@xxxxxxxxx>
---
drivers/block/floppy.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index f04397b8e381..85eac9adc385 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4052,8 +4052,12 @@ static int floppy_open(struct gendisk *disk, blk_mode_t mode)
drive_state[drive].last_checked = 0;
clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
&drive_state[drive].flags);
- if (disk_check_media_change(disk))
- floppy_revalidate(disk);
+ if (disk_check_media_change(disk)) {
+ res = floppy_revalidate(disk);
+ if (res)
+ goto out;
+ }
+ res = -ENXIO;
if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags))
goto out;
if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags))
base-commit: 2c3418fffa9d037b2038a6db48be63f9e2291806
--
2.55.0