From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753275AbbFHO3s (ORCPT ); Mon, 8 Jun 2015 10:29:48 -0400 Received: from foss.arm.com ([217.140.101.70]:48561 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932141AbbFHO3g (ORCPT ); Mon, 8 Jun 2015 10:29:36 -0400 From: Catalin Marinas To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Andrew Morton , vigneshr@codeaurora.org Subject: [PATCH v2 3/4] mm: kmemleak: Do not acquire scan_mutex in kmemleak_do_cleanup() Date: Mon, 8 Jun 2015 15:29:17 +0100 Message-Id: <1433773758-21994-4-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433773758-21994-1-git-send-email-catalin.marinas@arm.com> References: <1433773758-21994-1-git-send-email-catalin.marinas@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Andrew Morton --- mm/kmemleak.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index ecde522ff616..8a57e34625fa 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -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);