diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-05-08 09:46:12 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-05-08 15:18:24 +0200 |
commit | 714b248f03b6c858e19cc5e062df7d5bdc811821 (patch) | |
tree | 0e160d5097f6d7f4ab7d5f2d9367c30a7e1926b7 | |
parent | ba647f63f0d7a005c66821ace650a5ee170a7370 (diff) | |
download | barebox-714b248f03b6c858e19cc5e062df7d5bdc811821.tar.gz |
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 <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230508074612.3313870-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/block.c | 5 |
1 files changed, 5 insertions, 0 deletions
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); |