Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f369f37 authored by Catalin Marinas's avatar Catalin Marinas Committed by Linus Torvalds
Browse files

mm: kmemleak: do not acquire scan_mutex in kmemleak_do_cleanup()



The kmemleak_do_cleanup() work thread already waits for the kmemleak_scan
thread to finish via kthread_stop().  Waiting in kthread_stop() while
scan_mutex is held may lead to deadlock if kmemleak_scan_thread() also
waits to acquire for scan_mutex.

Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e781a9ab
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1762,7 +1762,6 @@ static void __kmemleak_do_cleanup(void)
 */
static void kmemleak_do_cleanup(struct work_struct *work)
{
	mutex_lock(&scan_mutex);
	stop_scan_thread();

	/*
@@ -1777,7 +1776,6 @@ static void kmemleak_do_cleanup(struct work_struct *work)
	else
		pr_info("Kmemleak disabled without freeing internal data. "
			"Reclaim the memory with \"echo clear > /sys/kernel/debug/kmemleak\"\n");
	mutex_unlock(&scan_mutex);
}

static DECLARE_WORK(cleanup_work, kmemleak_do_cleanup);