Received: by 10.213.65.68 with SMTP id h4csp523499imn; Fri, 16 Mar 2018 10:19:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELtCNqlTMAxiPhVOxzrodmn25661zgX4+qj/Qx77fs8TvMgrx6Zn1q+BcFAjp3O2QDBtRPAT X-Received: by 10.98.204.143 with SMTP id j15mr2216402pfk.60.1521220795249; Fri, 16 Mar 2018 10:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521220795; cv=none; d=google.com; s=arc-20160816; b=SzqP6NLiYqXlxlLWmNDdJM4Oq/pAs+75VX7hGqhVYIPnz13s0+VynJf1ExtzsKp5ap NN4koRqMDdXavCP1hdcjWJ7fMkirwYtkxCAOT2n8Fq+mYIf8j60vBr791TYkNfvnrQ4o RUshp9Y2Z1eOaArDVMB6qxGl/KdYRGIyciuso2R+EJHY+embtXYnnedxx9Rj1hkH88aB Y8oECXM+2CVvAKLRj7pDUDNW2rdX5govVKv/1UXd4BKi/T2SuZ5gIrhFqDt25IE3ZwPw hlcsuVRKJcET8qBcas3dZvZj+QuS/PZ9Puqy5gV99r8DzUl1Ss/z45YRzGOW4Khri/kX GkFA== 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=evm1RRKue0TfpYJNK3gOS4N1hjJLthoVZckHBcFjGmo=; b=YO08Jl5EDtd0zV5kOvy6H63twSTpFTufOe/VDALvLQyWd7Mc3ILPDAaNRjUSEwo90Z AT1Hr9TJJQs9+YwrqIPh3Nv9pwqV7WCS6loyo68E32+WfcbkI82KTU8iN0sxKUQ2Y8Vf UP/Ws6VhOC4DbymaLg/GWhb8Luu7bX8KL6WUuGsCijCvLmk6j4pqWe0GfSABJhlZIaxR DDg2cYMw9CD37klo2lDk50jYQbvP1n3VPzU6n0qFbiStP9Vaf/O6od9yFauVUFn4B/Cd NvHUMEeVys0pke/WDGlpUDyfIYIAsOh3jRs4T58V9LYR0GYyVP74sCc9hLxuO99ZFv9c bidA== 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 x5si5186539pgb.365.2018.03.16.10.19.40; Fri, 16 Mar 2018 10:19:55 -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 S933224AbeCPPa3 (ORCPT + 99 others); Fri, 16 Mar 2018 11:30:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36516 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754334AbeCPPaZ (ORCPT ); Fri, 16 Mar 2018 11:30:25 -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 8C9181148; Fri, 16 Mar 2018 15:30:24 +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.9 20/86] Input: matrix_keypad - fix race when disabling interrupts Date: Fri, 16 Mar 2018 16:22:43 +0100 Message-Id: <20180316152318.732409641@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152317.167709497@linuxfoundation.org> References: <20180316152317.167709497@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.9-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;