Skip to contentSkip to conversation

floppy: fail the open when floppy_revalidate() fails

PATCH New Denis Efremov (Oracle) 1 participant 1 message Oct 6

Subsystems (2)
lore
Share & tools
lore

Denis Efremov (Oracle)

author maintainer
#0 lore raw

PATCH 1/1 floppy: fail the open when floppy_revalidate() fails

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")
---
 drivers/block/floppy.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/block/floppy.c +6 -2
index f04397b8e381..85eac9adc385 100644
@@ -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

Signature · 1 line
2.55.0