diff options
author | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-02-12 22:03:07 +0100 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-03-15 17:25:05 +0100 |
commit | c585da9f5f6186739f0b123b8a5b6353e425f51b (patch) | |
tree | b264d83d56b70e66a28f74ce83f1c4d18fc76813 /drivers/mtd/mtdcore.c | |
parent | mtd: st_spi_fsm: use %*ph to print small buffer (diff) | |
download | linux-c585da9f5f6186739f0b123b8a5b6353e425f51b.tar.xz linux-c585da9f5f6186739f0b123b8a5b6353e425f51b.zip |
mtd: Initialize ->fail_addr early in mtd_erase()
mtd_erase() can return an error before ->fail_addr is initialized to
MTD_FAIL_ADDR_UNKNOWN. Move this initialization at the very beginning
of the function.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r-- | drivers/mtd/mtdcore.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index a1c94526fb88..c87859ff338b 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -953,6 +953,8 @@ EXPORT_SYMBOL_GPL(__put_mtd_device); */ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) { + instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; + if (!mtd->erasesize || !mtd->_erase) return -ENOTSUPP; @@ -961,7 +963,6 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) if (!(mtd->flags & MTD_WRITEABLE)) return -EROFS; - instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; if (!instr->len) { instr->state = MTD_ERASE_DONE; mtd_erase_callback(instr); |