From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mandeep Singh Baines Subject: [PATCH] thinkpad-acpi: fix potential suspend blocking issue Date: Tue, 5 Mar 2013 09:34:43 -0800 Message-ID: <1362504883-9180-1-git-send-email-msb@chromium.org> References: <201303042055.38040.maciej.rutecki@gmail.com> Return-path: In-Reply-To: <201303042055.38040.maciej.rutecki@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, ibm-acpi@hmh.eng.br, ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Cc: Mandeep Singh Baines , Aaron Lu , Henrique de Moraes Holschuh , Tejun Heo , Oleg Nesterov , Andrew Morton List-Id: platform-driver-x86.vger.kernel.org Fixes the following lockdep error: [ BUG: ktpacpi_nvramd/446 still has locks held! ] hotkey_kthread() calls set_freezable() after acquiring the hotkey_kthread_mutex(). set_freezable() calls try_to_freeze(). This could block suspend if we were to freeze at this point and another task were to block on the mutex, potentially via writing to one of the sysfs attrs. This race is unlikely but can be easily fixed by moving the set_freezable() call. Reported-by: Maciej Rutecki Signed-off-by: Mandeep Singh Baines CC: Aaron Lu CC: Henrique de Moraes Holschuh CC: Tejun Heo CC: Oleg Nesterov CC: Andrew Morton --- drivers/platform/x86/thinkpad_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 9a90756..69870a841 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -2462,13 +2462,13 @@ static int hotkey_kthread(void *data) unsigned int poll_freq; bool was_frozen; + set_freezable(); + mutex_lock(&hotkey_thread_mutex); if (tpacpi_lifecycle == TPACPI_LIFE_EXITING) goto exit; - set_freezable(); - so = 0; si = 1; t = 0; -- 1.7.12.4