mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 2/2] block: refuse registering block devices with absurdly large blocks
Date: Mon,  8 May 2023 09:46:12 +0200	[thread overview]
Message-ID: <20230508074612.3313870-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230508074612.3313870-1-a.fatoum@pengutronix.de>

Block layer caching can't work if a block is bigger than BUFSIZE which
is used for the caching chunks. Instead of ending up with a rdbufsize
of 0, which leads to strange errors on device access, just refuse this
outright.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/block.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/block.c b/common/block.c
index 7f28b56419e2..c39269d3a692 100644
--- a/common/block.c
+++ b/common/block.c
@@ -388,6 +388,11 @@ int blockdevice_register(struct block_device *blk)
 	dev_dbg(blk->dev, "rdbufsize: %d blockbits: %d blkmask: 0x%08x\n",
 		blk->rdbufsize, blk->blockbits, blk->blkmask);
 
+	if (!blk->rdbufsize) {
+		pr_warn("block size of %u not supported\n", BLOCKSIZE(blk));
+		return -ENOSYS;
+	}
+
 	for (i = 0; i < 8; i++) {
 		struct chunk *chunk = xzalloc(sizeof(*chunk));
 		chunk->data = dma_alloc(BUFSIZE);
-- 
2.39.2




  reply	other threads:[~2023-05-08  7:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08  7:46 [PATCH master 1/2] fs: fail gracefully in get_mounted_path/get_cdev_by_mountpath Ahmad Fatoum
2023-05-08  7:46 ` Ahmad Fatoum [this message]
2023-05-08 13:18 ` Sascha Hauer

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=20230508074612.3313870-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox