Patchwork block2mtd: dubious assignment

login
register
mail settings
Submitter Nicolas Kaiser
Date Oct. 22, 2010, 10:47 a.m.
Message ID <20101022124724.59eba464@absol.kitzblitz>
Download mbox | patch
Permalink /patch/68835/
State New
Headers show

Comments

Nicolas Kaiser - Oct. 22, 2010, 10:47 a.m.
When block2mtd_erase fails, a duplicated assignment instantly
changes instr->state from MTD_ERASE_FAILED to MTD_ERASE_DONE.

It looks to me like this might not be intended, or is it?

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
---
 drivers/mtd/devices/block2mtd.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
Jörn Engel - Oct. 22, 2010, 2:34 p.m.
On Fri, 22 October 2010 12:47:24 +0200, Nicolas Kaiser wrote:
> 
> When block2mtd_erase fails, a duplicated assignment instantly
> changes instr->state from MTD_ERASE_FAILED to MTD_ERASE_DONE.
> 
> It looks to me like this might not be intended, or is it?

Definitely not.  Just proves how well block device errors are tested.

> Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
Acked-By: Joern Engel <joern@logfs.org>

Artem, can I leave this patch to you as well?

Jörn
Artem Bityutskiy - Oct. 22, 2010, 4:13 p.m.
On Fri, 2010-10-22 at 16:34 +0200, Jörn Engel wrote:
> On Fri, 22 October 2010 12:47:24 +0200, Nicolas Kaiser wrote:
> > 
> > When block2mtd_erase fails, a duplicated assignment instantly
> > changes instr->state from MTD_ERASE_FAILED to MTD_ERASE_DONE.
> > 
> > It looks to me like this might not be intended, or is it?
> 
> Definitely not.  Just proves how well block device errors are tested.
> 
> > Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
> Acked-By: Joern Engel <joern@logfs.org>
> 
> Artem, can I leave this patch to you as well?

Yes, I'll put it to my l2 tree of course, thanks.

Patch

diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 9365186..2cf0cc6 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -91,7 +91,6 @@  static int block2mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
 	} else
 		instr->state = MTD_ERASE_DONE;
 
-	instr->state = MTD_ERASE_DONE;
 	mtd_erase_callback(instr);
 	return err;
 }