Skip to content

Commit

Permalink
mm: kmemleak: do not acquire scan_mutex in kmemleak_do_cleanup()
Browse files Browse the repository at this point in the history
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: Catalin Marinas <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
ctmarinas authored and torvalds committed Jun 25, 2015
1 parent e781a9a commit 5f369f3
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions mm/kmemleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/*
Expand All @@ -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);
Expand Down

0 comments on commit 5f369f3

Please sign in to comment.