• Richard Weinberger's avatar
    ubi: fastmap: Cancel work upon detach · 6e7d8016
    Richard Weinberger authored
    Ben Hutchings pointed out that 29b7a6fa ("ubi: fastmap: Don't flush
    fastmap work on detach") does not really fix the problem, it just
    reduces the risk to hit the race window where fastmap work races against
    free()'ing ubi->volumes[].
    
    The correct approach is making sure that no more fastmap work is in
    progress before we free ubi data structures.
    So we cancel fastmap work right after the ubi background thread is
    stopped.
    By setting ubi->thread_enabled to zero we make sure that no further work
    tries to wake the thread.
    
    Fixes: 29b7a6fa ("ubi: fastmap: Don't flush fastmap work on detach")
    Fixes: 74cdaf24 ("UBI: Fastmap: Fix memory leaks while closing the WL sub-system")
    Cc: [email protected]
    Cc: Ben Hutchings <[email protected]>
    Cc: Martin Townsend <[email protected]>
    Signed-off-by: default avatarRichard Weinberger <[email protected]>
    6e7d8016
wl.c 51.8 KB