From patchwork Wed Jun 13 10:42:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [07/21] UBI: Fastmap: Prevent PEB leak Date: Wed, 13 Jun 2012 00:42:04 -0000 From: Richard Weinberger X-Patchwork-Id: 164624 Message-Id: <1339584138-69914-8-git-send-email-richard@nod.at> To: linux-mtd@lists.infradead.org Cc: Richard Weinberger , adrian.hunter@intel.com, Heinz.Egger@linutronix.de, shmulik.ladkani@gmail.com, tglx@linutronix.de, tim.bird@am.sony.com Before writing the new fastmap we have to ensure that no PEBs are in flight. Signed-off-by: Richard Weinberger --- drivers/mtd/ubi/fastmap.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index c2a1c18..82a011d 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c @@ -1366,6 +1366,14 @@ int ubi_update_fastmap(struct ubi_device *ubi) kfree(old_fm); } + /* Ensure that the PEBs of the old fastmap got erased and added to the + * free list before we write the fastmap. Otherwise fastmp does not + * see these PEBs and we leak them. + * FIXME: Rewrite ubi_wl_flush() such that we can flush only the + * erase work instead of all work. + */ + ubi_wl_flush(ubi); + ret = ubi_write_fastmap(ubi, new_fm); out_unlock: mutex_unlock(&ubi->fm_mutex);