mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-26 14:40:41 +00:00
sf: Guard against zero erasesize
With tiny SPI flash the erasesize is 0 which can cause a divide-by-zero error. Check for this and return a proper error instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
f2fac8b557
commit
28afcb1e7f
1 changed files with 2 additions and 1 deletions
|
@ -189,7 +189,8 @@ static int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
|
||||||
struct mtd_info *mtd = &flash->mtd;
|
struct mtd_info *mtd = &flash->mtd;
|
||||||
struct erase_info instr;
|
struct erase_info instr;
|
||||||
|
|
||||||
if (offset % mtd->erasesize || len % mtd->erasesize) {
|
if (!mtd->erasesize ||
|
||||||
|
(offset % mtd->erasesize || len % mtd->erasesize)) {
|
||||||
debug("SF: Erase offset/length not multiple of erase size\n");
|
debug("SF: Erase offset/length not multiple of erase size\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue