summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2017-03-01 16:57:03 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-02 08:41:53 +0100
commitfaa369e9c55aa3b1f92bdb6a08d040af228ecedd (patch)
treee164ac7fe3b2113516621f86b5b073f57f52c1e5
parente0ff988ad865f3370ddeb8e75eefd9ed27d6641b (diff)
downloadbarebox-faa369e9c55aa3b1f92bdb6a08d040af228ecedd.tar.gz
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>
-rw-r--r--drivers/mtd/nand/nand-bb.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
index 015f8dc..a1523c3 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;