mtd: mtd_blk: Map table length round up to erase size

Change-Id: I5f615d37a572ce0d8ceb8d6d6b76983fc61e316b
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
This commit is contained in:
Jon Lin 2020-08-25 20:39:45 +08:00 committed by Jianhong Chen
parent 51ceae363d
commit e091dc9d13
1 changed files with 2 additions and 1 deletions

View File

@ -59,7 +59,8 @@ int mtd_blk_map_table_init(struct blk_desc *desc,
} }
blk_begin = (u32)offset >> mtd->erasesize_shift; blk_begin = (u32)offset >> mtd->erasesize_shift;
blk_cnt = ((u32)((offset & mtd->erasesize_mask) + length) >> mtd->erasesize_shift); blk_cnt = ((u32)((offset & mtd->erasesize_mask) + length + \
mtd->erasesize - 1) >> mtd->erasesize_shift);
if (blk_begin >= blk_total) { if (blk_begin >= blk_total) {
pr_err("map table blk begin[%d] overflow\n", blk_begin); pr_err("map table blk begin[%d] overflow\n", blk_begin);
return -EINVAL; return -EINVAL;