From 714b248f03b6c858e19cc5e062df7d5bdc811821 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 8 May 2023 09:46:12 +0200 Subject: block: refuse registering block devices with absurdly large blocks 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 Link: https://lore.barebox.org/20230508074612.3313870-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- common/block.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/block.c b/common/block.c index 7f28b56419..c39269d3a6 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); -- cgit v1.2.1