From faa369e9c55aa3b1f92bdb6a08d040af228ecedd Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Wed, 1 Mar 2017 16:57:03 +0100 Subject: nand-bb: fix writing to the end of a .bb device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Sascha Hauer --- drivers/mtd/nand/nand-bb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c index 015f8dc524..a1523c3c89 100644 --- a/drivers/mtd/nand/nand-bb.c +++ b/drivers/mtd/nand/nand-bb.c @@ -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; -- cgit v1.2.3