9
0
Fork 0

nand-bb: fix writing to the end of a .bb device

As nand_bb_write_buf calls mtd_write(bb->mtd, cur_ofs, now, ...) the
limit that now should be checked against is bb->mtd->size - cur_ofs.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Uwe Kleine-König 2017-03-01 16:57:03 +01:00 committed by Sascha Hauer
parent e0ff988ad8
commit faa369e9c5
1 changed files with 1 additions and 1 deletions

View File

@ -99,7 +99,7 @@ static int nand_bb_write_buf(struct nand_bb *bb, size_t count)
loff_t cur_ofs = bb->offset & ~(BB_WRITEBUF_SIZE - 1);
while (count) {
loff_t max = bb->mtd->size - bb->offset;
loff_t max = bb->mtd->size - cur_ofs;
if (max <= 0)
return -ENOSPC;