9
0
Fork 0

NAND: fix reading of bad block aware devices

When reading from bad block aware devices we must make sure not
to read beyond eraseblock boundaries.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2008-09-03 14:04:15 +02:00
parent 9fc8c4e9bb
commit f118d1a103
1 changed files with 4 additions and 2 deletions

View File

@ -62,7 +62,8 @@ static ssize_t nand_bb_read(struct device_d *dev, void *buf, size_t count,
bb->offset += bb->info.erasesize;
}
now = min(count, bb->info.erasesize);
now = min(count, (size_t)(bb->info.erasesize -
(bb->offset % bb->info.erasesize)));
ret = dev_read(bb->physdev, buf, now, bb->offset, flags);
if (ret < 0)
return ret;
@ -93,7 +94,8 @@ static ssize_t nand_bb_write(struct device_d *dev, const void *buf, size_t count
bb->offset += bb->info.erasesize;
}
now = min(count, bb->info.erasesize);
now = min(count, (size_t)(bb->info.erasesize -
(bb->offset % bb->info.erasesize)));
ret = dev_write(bb->physdev, buf, now, bb->offset, flags);
if (ret < 0)
return ret;