All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Anders Grafström" <grfstrm@users.sourceforge.net>
To: dwmw2@infradead.org
Cc: Linux-MTD Mailing List <linux-mtd@lists.infradead.org>
Subject: [PATCH] Fix return values of jffs2_block_check_erase
Date: Mon, 14 Apr 2008 13:42:05 +0200	[thread overview]
Message-ID: <4803430D.2050201@users.sourceforge.net> (raw)

Corrects the return values of the error paths so that a block
that failed to be erased is marked as bad instead of being reused.

Signed-off-by: Anders Grafström <grfstrm@users.sourceforge.net>
---
  fs/jffs2/erase.c |    7 ++++++-
  1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index a1db918..23e9dd6 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -350,9 +350,11 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
  			   break;
  		} while(--retlen);
  		c->mtd->unpoint(c->mtd, ebuf, jeb->offset, c->sector_size);
-		if (retlen)
+		if (retlen) {
  			printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n",
  			       *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf));
+			return -EIO;
+		}
  		return 0;
  	}
   do_flash_read:
@@ -373,10 +375,12 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
  		ret = c->mtd->read(c->mtd, ofs, readlen, &retlen, ebuf);
  		if (ret) {
  			printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret);
+			ret = -EIO;
  			goto fail;
  		}
  		if (retlen != readlen) {
  			printk(KERN_WARNING "Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", ofs, readlen, retlen);
+			ret = -EIO;
  			goto fail;
  		}
  		for (i=0; i<readlen; i += sizeof(unsigned long)) {
@@ -385,6 +389,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
  			if (*datum + 1) {
  				*bad_offset += i;
  				printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset);
+				ret = -EIO;
  				goto fail;
  			}
  		}
-- 
1.5.4.4

                 reply	other threads:[~2008-04-14 11:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4803430D.2050201@users.sourceforge.net \
    --to=grfstrm@users.sourceforge.net \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.