ubi: Fix races around ubi_refill_pools()
authorRichard Weinberger <richard@nod.at>
Wed, 24 Aug 2016 12:36:14 +0000 (14:36 +0200)
committerRichard Weinberger <richard@nod.at>
Sun, 2 Oct 2016 20:54:01 +0000 (22:54 +0200)
commit2e8f08deabbc7eefe4c5838aaa6aa9a23a8acf2e
tree978c8095e114898a898df44014996611a39ddfef
parent2365418879e9abf12ea9def7f9f3caf0dfa7ffb0
ubi: Fix races around ubi_refill_pools()

When writing a new Fastmap the first thing that happens
is refilling the pools in memory.
At this stage it is possible that new PEBs from the new pools
get already claimed and written with data.
If this happens before the new Fastmap data structure hits the
flash and we face power cut the freshly written PEB will not
scanned and unnoticed.

Solve the issue by locking the pools until Fastmap is written.

Cc: <stable@vger.kernel.org>
Fixes: dbb7d2a88d ("UBI: Add fastmap core")
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/eba.c
drivers/mtd/ubi/fastmap-wl.c
drivers/mtd/ubi/fastmap.c
drivers/mtd/ubi/wl.c