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

Commit 88852130 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm/kmemleak.c: wait for scan completion before disabling free" into msm-4.14

parents c313b8a7 002720e7
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -1670,8 +1670,7 @@ static void start_scan_thread(void)
}

/*
 * Stop the automatic memory scanning thread. This function must be called
 * with the scan_mutex held.
 * Stop the automatic memory scanning thread.
 */
static void stop_scan_thread(void)
{
@@ -1934,12 +1933,15 @@ static void kmemleak_do_cleanup(struct work_struct *work)
{
	stop_scan_thread();

	mutex_lock(&scan_mutex);
	/*
	 * Once the scan thread has stopped, it is safe to no longer track
	 * object freeing. Ordering of the scan thread stopping and the memory
	 * accesses below is guaranteed by the kthread_stop() function.
	 * Once it is made sure that kmemleak_scan has stopped, it is safe to no
	 * longer track object freeing. Ordering of the scan thread stopping and
	 * the memory accesses below is guaranteed by the kthread_stop()
	 * function.
	 */
	kmemleak_free_enabled = 0;
	mutex_unlock(&scan_mutex);

	if (!kmemleak_found_leaks)
		__kmemleak_do_cleanup();