mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Johannes Stezenbach <js@sig21.net>
To: barebox@lists.infradead.org
Subject: [PATCH 1/5] m25p80: prevent endless loop in erase
Date: Wed,  6 Jun 2012 18:04:56 +0200	[thread overview]
Message-ID: <1338998700-23012-2-git-send-email-js@sig21.net> (raw)
In-Reply-To: <1338998700-23012-1-git-send-email-js@sig21.net>

"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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-06-06 16:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-06 16:04 [PATCH 0/5] minor SPI flash fixes Johannes Stezenbach
2012-06-06 16:04 ` Johannes Stezenbach [this message]
2012-06-06 16:04 ` [PATCH 2/5] m25p80: allow erase to be interrupted Johannes Stezenbach
2012-06-06 16:04 ` [PATCH 3/5] m25p80: progressbar tweak Johannes Stezenbach
2012-06-06 16:04 ` [PATCH 4/5] devfs: don't erase past the end of the partition Johannes Stezenbach
2012-06-06 16:05 ` [PATCH 5/5] fs: limit flash erase and protect to the partiton boundary Johannes Stezenbach
2012-06-07 17:32 ` [PATCH 0/5] minor SPI flash fixes Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338998700-23012-2-git-send-email-js@sig21.net \
    --to=js@sig21.net \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox