Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17928591ybl; Thu, 2 Jan 2020 15:01:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyteufFW6862GJkG4IVU4ctZrF+UU8OLXhJXLttnTrl3GV9BxnLmX2GBMJs2535rkD+6elE X-Received: by 2002:a9d:6e98:: with SMTP id a24mr77431737otr.109.1578006063469; Thu, 02 Jan 2020 15:01:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006063; cv=none; d=google.com; s=arc-20160816; b=Y2Ei5p7iCyjV5NIU4E3DpVdSR5IdI8j1dVfwIS7VctlNL9Dg9xYFAu5xrdkINSOSpE V3IwajzOoKbMorNZ+YQpXRgLQlVB2qsmU2Yhfm5QjUZ8wZbMZ9wkJPBYKtorQajSiGGT dMCD3sgHXhwnmKAgZrpvJvIOHw8QmT0QsCVjYLpMo4iJfY7+Qi3HvNAYazeJxL9j7JkO YTSgOsfniT5dgJ1RS77sPYnvBVRyRBWeEwBZNmmA6tw+eHd1YrfCjqqVFVuN7VVCy83y qEAnf6dKzuzdYYn4kWxDXmh+luqYVD2PnlzrfIqcchQklDHFZh9Vc+fnsIbAfGnucLax 69aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vEOqjY70O4ia2mhlRlFFUb64PngzlZf7Nk66rW2Ar80=; b=w0AMTN1UNbfeZ0Wcd5hq45NtscdSEay/0Ywg30txmfrSmrXSRP2Vz9q9Al9MPq8XxG iP7zSdyVoLnBGi1enhb1JfdVr/f3P28/niR9fqSglYH+123F5PUw+cD3LuA38NVNea6A oBo8CjhkWYmyDPWDOTECB6tOKQ46IvDH+mBjVpZTqwV9TA6x20oMG3w6zq6ch8iRl0ys a21FRelCw2O1wLhjgF5VTQdOw8k/zOoIkKBXhWBP1CqTvsVSAyoqvqoDOWzDXV73Njy/ 5Fb7ApP0Eoq4/t1R5fb+V2KrjqSAOJoXV/xsyifv6W60foNUvJUGnOEViIizvQGnLMn5 pa/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="FJSb/B7t"; 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 u125si28050873oif.130.2020.01.02.15.00.51; Thu, 02 Jan 2020 15:01:03 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="FJSb/B7t"; 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 S1727868AbgABWOP (ORCPT + 99 others); Thu, 2 Jan 2020 17:14:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:54378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727852AbgABWOM (ORCPT ); Thu, 2 Jan 2020 17:14:12 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C94E24653; Thu, 2 Jan 2020 22:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003251; bh=RgwvjIZONL5ZWANMEt1LiIYYnYCkycmum9J0tQGrhDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJSb/B7tmpGbHxaZiOokRtbPEtotaGJqaWsgq1Q1BE73fc9p65spFRuPDCpNa/v0B S/vmNHZ0Y4QeQ2CNLlHgtCVU74ME9EOgWGOvO66Dg65pJdlDfINsc7U4A2AsIHzezw iUnJJycg+DTCN0e79iUgIbeSkUGON7yKI8zZ7xqQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Duggan , Federico Cerutti , Jiri Kosina , Sasha Levin Subject: [PATCH 5.4 082/191] HID: rmi: Check that the RMI_STARTED bit is set before unregistering the RMI transport device Date: Thu, 2 Jan 2020 23:06:04 +0100 Message-Id: <20200102215838.729753573@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Duggan [ Upstream commit 8725aa4fa7ded30211ebd28bb1c9bae806eb3841 ] In the event that the RMI device is unreachable, the calls to rmi_set_mode() or rmi_set_page() will fail before registering the RMI transport device. When the device is removed, rmi_remove() will call rmi_unregister_transport_device() which will attempt to access the rmi_dev pointer which was not set. This patch adds a check of the RMI_STARTED bit before calling rmi_unregister_transport_device(). The RMI_STARTED bit is only set after rmi_register_transport_device() completes successfully. The kernel oops was reported in this message: https://www.spinics.net/lists/linux-input/msg58433.html [jkosina@suse.cz: reworded changelog as agreed with Andrew] Signed-off-by: Andrew Duggan Reported-by: Federico Cerutti Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-rmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 7c6abd7e0979..9ce22acdfaca 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -744,7 +744,8 @@ static void rmi_remove(struct hid_device *hdev) { struct rmi_data *hdata = hid_get_drvdata(hdev); - if (hdata->device_flags & RMI_DEVICE) { + if ((hdata->device_flags & RMI_DEVICE) + && test_bit(RMI_STARTED, &hdata->flags)) { clear_bit(RMI_STARTED, &hdata->flags); cancel_work_sync(&hdata->reset_work); rmi_unregister_transport_device(&hdata->xport); -- 2.20.1