mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-05-02 18:17:50 -04:00
ubi: fastmap: Cancel work upon detach
Ben Hutchings pointed out that29b7a6fa1e("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:29b7a6fa1e("ubi: fastmap: Don't flush fastmap work on detach") Fixes:74cdaf2400("UBI: Fastmap: Fix memory leaks while closing the WL sub-system") Cc: stable@vger.kernel.org Cc: Ben Hutchings <ben.hutchings@codethink.co.uk> Cc: Martin Townsend <mtownsend1973@gmail.com> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
@@ -1091,6 +1091,9 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
|
||||
if (ubi->bgt_thread)
|
||||
kthread_stop(ubi->bgt_thread);
|
||||
|
||||
#ifdef CONFIG_MTD_UBI_FASTMAP
|
||||
cancel_work_sync(&ubi->fm_work);
|
||||
#endif
|
||||
ubi_debugfs_exit_dev(ubi);
|
||||
uif_close(ubi);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user