All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Denis Efremov (Oracle)" <efremov@linux.com>
To: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Denis Efremov (Oracle)" <efremov@linux.com>
Subject: [PATCH] floppy: fail the open when floppy_revalidate() fails
Date: Tue,  6 Oct 2026 14:02:58 +0400	[thread overview]
Message-ID: <20261006100258.1871870-1-efremov@linux.com> (raw)

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@linux.com>
---
 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


                 reply	other threads:[~2026-10-06 10:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261006100258.1871870-1-efremov@linux.com \
    --to=efremov@linux.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.