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>
struct mtd_info *mtd = &flash->mtd;
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");
return -EINVAL;
}