mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-03-13 21:36:57 +00:00
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>
This commit is contained in:
parent
0491cb8f9b
commit
e261fbf347
1 changed files with 5 additions and 0 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue