diff options
author | Bin Meng <bmeng@tinylab.org> | 2023-09-26 16:43:35 +0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-10 16:19:43 -0400 |
commit | e261fbf347854c75de50dd410904b436d49a7636 (patch) | |
tree | 11cca4697bf16f74ab51db4f8152b376267c067c /drivers | |
parent | 0491cb8f9b819e90d02c33c7fb73b6dc70722e0a (diff) | |
download | u-boot-e261fbf347854c75de50dd410904b436d49a7636.tar.gz u-boot-e261fbf347854c75de50dd410904b436d49a7636.tar.bz2 u-boot-e261fbf347854c75de50dd410904b436d49a7636.zip |
blk: host_dev: Sanity check on the size of host backing file
Since we are emulating a block device, its size should be multiple
of the configured block size.
Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/host_dev.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/block/host_dev.c b/drivers/block/host_dev.c index 0b43f80a86..30c7415793 100644 --- a/drivers/block/host_dev.c +++ b/drivers/block/host_dev.c @@ -58,6 +58,11 @@ static int host_sb_attach_file(struct udevice *dev, const char *filename) size = os_filesize(fd); desc = dev_get_uclass_plat(blk); + if (size % desc->blksz) { + printf("The size of host backing file '%s' is not multiple of " + "the device block size\n", filename); + goto err_fname; + } desc->lba = size / desc->blksz; /* write this in last, when nothing can go wrong */ |