Received: by 10.213.65.68 with SMTP id h4csp529004imn; Fri, 16 Mar 2018 10:29:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELsUhVmKgVZtZee49IOOc5wfVot8Sm9hD6rFYzibjum/JzT88jvGwz1OnsWz3zZZfcNMf3xK X-Received: by 10.98.152.207 with SMTP id d76mr2215279pfk.130.1521221397645; Fri, 16 Mar 2018 10:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521221397; cv=none; d=google.com; s=arc-20160816; b=g+nB1nAxXpqcfo2f+hK9ec38nXIClTKuWkFbfWSHgGI9mv7MMmkg5ICoecwUB6GiFL 36V926Gkn4bnVc0koKkXg0FZWjhIVSC1fzvu579C35d8OxOHZdc3c+4nhgZ6embhf+6l GjHb/ZCV/6m4RtWxu8aGj8JbxNNyMQiYlV7x5fudxEVuH3NnHSWMftjLiUrpQAFHffZQ Z+/x+bxMeFYeR+OSXumKhpdN6wB6uTz0vmwPFkcAQVURAv5PPtdoqUs5UQdo/7lw+7XF m9ZX+Hwmw7lgElx3OZ5GP88uvmNbIcmHyKuRyImDatTMYQl+f+DqW+cHsbG0/OiZafbb AAhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=82wkAr+oAxUqLHAYWMVLy4gBFBPJcamqubdu0GxGaqs=; b=H1pbXWpMidOGhCxEjdlZ/+cMbssJk/RxeEPzhY89ff/5dHxn7Zb1Sx2eghdNNbTwkX bqwBGM52YRaYcBXJkKyzZnIKDYazftfRCjdpMqvFrl/+AMIrNc7hn7NhCwfav/BQTeeJ EltA3UDF/m40QqysYZGvs2DVwaio94nIJE3n0ohBSRkfDGdxnucL0rJoJFk82Yp5DlSD 45oxtrdUDyub4w6kY54pTyuNkLx+qfIWFBjR/viyeG8zzNjn7PVG5raIKJ5ls6QrpU84 osAfBDVwojm8Uxb2oWj8UXgml6kLZ9XV+VuV8P+DljJv+kfm4P6uxgcb30BEZYXs5ptF /NXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si5200638pgr.152.2018.03.16.10.29.43; Fri, 16 Mar 2018 10:29:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753117AbeCPR1h (ORCPT + 99 others); Fri, 16 Mar 2018 13:27:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35702 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754016AbeCPP23 (ORCPT ); Fri, 16 Mar 2018 11:28:29 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AADA0C8A; Fri, 16 Mar 2018 15:28:28 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Bo , Dmitry Torokhov Subject: [PATCH 4.4 16/63] Input: matrix_keypad - fix race when disabling interrupts Date: Fri, 16 Mar 2018 16:22:48 +0100 Message-Id: <20180316152301.844228094@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152259.964532775@linuxfoundation.org> References: <20180316152259.964532775@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhang Bo commit ea4f7bd2aca9f68470e9aac0fc9432fd180b1fe7 upstream. If matrix_keypad_stop() is executing and the keypad interrupt is triggered, disable_row_irqs() may be called by both matrix_keypad_interrupt() and matrix_keypad_stop() at the same time, causing interrupts to be disabled twice and the keypad being "stuck" after resuming. Take lock when setting keypad->stopped to ensure that ISR will not race with matrix_keypad_stop() disabling interrupts. Signed-off-by: Zhang Bo Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/keyboard/matrix_keypad.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c @@ -216,8 +216,10 @@ static void matrix_keypad_stop(struct in { struct matrix_keypad *keypad = input_get_drvdata(dev); + spin_lock_irq(&keypad->lock); keypad->stopped = true; - mb(); + spin_unlock_irq(&keypad->lock); + flush_work(&keypad->work.work); /* * matrix_keypad_scan() will leave IRQs enabled;