mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-27 22:56:49 +08:00
virtio_blk: set log2blksz correctly
'log2blksz' in blk_desc structure must always be initialized, otherwise
it will cause a lot of weird failures in file operations.
For example, fs_set_blk_dev[_with_part]() examines a block device against
every file system with its probe function. In particular, ext4 file
system's ext4_probe() will calls fs_devread() to fetch a super block.
If log2blksz is 0, the actual 'read' size, i.e. block_len >> log2blksz, is
much bigger than a buffer's size, and it can end up with memory corruption.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Fixes: f4802209e5
("virtio: Add block driver support")
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
91f6c1ca2e
commit
6b0ddd1fbc
@ -115,6 +115,7 @@ static int virtio_blk_probe(struct udevice *dev)
|
||||
return ret;
|
||||
|
||||
desc->blksz = 512;
|
||||
desc->log2blksz = 9;
|
||||
virtio_cread(dev, struct virtio_blk_config, capacity, &cap);
|
||||
desc->lba = cap;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user