• Richard Weinberger's avatar
    ubi: Fix races around ubi_refill_pools() · 2092c83c
    Richard Weinberger authored
    commit 2e8f08de upstream.
    
    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.
    
    Fixes: dbb7d2a8 ("UBI: Add fastmap core")
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    [bwh: Backported to 3.16:
     - Adjust filename, context, indentation
     - s/ubi->fm_eba_sem/ubi->fm_sem/]
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    2092c83c
wl.c 56.3 KB