[PATCH 1/5] m25p80: prevent endless loop in erase
Johannes Stezenbach
js at sig21.net
Wed Jun 6 12:04:56 EDT 2012
"erase /dev/myflash0 0+1" erased the whole flash,
similar for other value of count if you guessed the
erae block size wrong.
Signed-off-by: Johannes Stezenbach <js at sig21.net>
---
drivers/nor/m25p80.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
index 92b07af..a3dfe75 100644
--- a/drivers/nor/m25p80.c
+++ b/drivers/nor/m25p80.c
@@ -235,6 +235,8 @@ static ssize_t m25p80_erase(struct cdev *cdev, size_t count, unsigned long offse
if (erase_sector(flash, addr))
return -EIO;
+ if (len <= flash->erasesize)
+ break;
addr += flash->erasesize;
len -= flash->erasesize;
show_progress(progress++);
--
1.7.10
More information about the barebox
mailing list