Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2230318imm; Thu, 7 Jun 2018 07:25:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKHuVg4bQp69vPyCql8o70bxgSlFUoP2miJZkGq0WvwABPomX1Lp53JFgZt+z590Yi+BJx5 X-Received: by 2002:a63:aa4c:: with SMTP id x12-v6mr1709654pgo.387.1528381500389; Thu, 07 Jun 2018 07:25:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528381500; cv=none; d=google.com; s=arc-20160816; b=BC30b10IBH7/5ZZdhmLmDjl7oRGvcubQmSlMUfNO8rbQiLc/mXI06DWA98o+BzxVUA vEU+x02E0IvAXUlXuh5BQzJZSGMEkcxaxdH9byPjOAUEUXuv/hHqGI0Ds1LIp90TPNcu +kns5vEZJWb1jPmxENr2gRvs3JOuWBbYjT3cKMvI2T7MP22mMVUW+xlPVlyMJlTnjUUj OUtzOY95Z6z+0LRvDQQD6/zv2qj2QvsYbZpXFvRmYHyhmQPuRZ0SqQEiqd8poCc7Kbbj TEtPKaetqm5oJsfIKsYQP3hU4NPW42xqDPa+tWvfIKX8QTmxnoIz/vwMAL8DVesKdMfS CvMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=PFXqNtWiBhyY11vuqwcuS+BTbiif+pQBdbClhfDlTpw=; b=luNsiUiYZ7w41cRcggGfSjj4jY7wiL8ao1j06C+ZqEmGFJZ9uzFLNXkLn64mwkXdBQ obIvGG1e0hGAaexbevahERM3iISN6UdXirVaVD/w4FDP2Wv16dv0AG99WsG21Cu7QsI8 glpbe3RcpPAPATKMlXsHOTdP1/N9fCcZvYdFGvkmU6Ahdsa6MRUGGtV39Bvh/ejblQiL fp6ZxXYCmDbkpg4nUx8IYdz+RLZPUMxGNDnWDpBKCoUvEX2dtxzusxDwitNspOoBPtqX zHBeRHed+Cp9+a400WQWiIKSDcaJLUq6OE8THPNR3/AsaW4pMZI3gsff+72hTx6xitiQ O1fA== 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 l1-v6si53956002pld.493.2018.06.07.07.24.45; Thu, 07 Jun 2018 07:25:00 -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 S933604AbeFGOWG (ORCPT + 99 others); Thu, 7 Jun 2018 10:22:06 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39430 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933070AbeFGOJK (ORCPT ); Thu, 7 Jun 2018 10:09:10 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbA-0005Zl-MB; Thu, 07 Jun 2018 15:09:08 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb7-00032Z-1k; Thu, 07 Jun 2018 15:09:05 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Dmitry Torokhov" , "Zhang Bo" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 224/410] Input: matrix_keypad - fix race when disabling interrupts In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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 Signed-off-by: Dmitry Torokhov Signed-off-by: Ben Hutchings --- 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;