Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17935255ybl; Thu, 2 Jan 2020 15:07:30 -0800 (PST) X-Google-Smtp-Source: APXvYqzkmOhl36fU7NH7IV88uVycdbzd/MWyDOv3m7CMG4GEGuDd3H0nAjqzBLjXjZ9veRF65ezV X-Received: by 2002:a9d:402:: with SMTP id 2mr35749200otc.357.1578006450198; Thu, 02 Jan 2020 15:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006450; cv=none; d=google.com; s=arc-20160816; b=Mu4GoyHRdsN3GLfz+CsSfcgsZJAD93iL0DKnT+Y4ssD/o9hEvbENSPusEucTD6C7Pp oPhCJ891idICOy1iOLP+lV5A/JsNyKJ48NaBAnX7G4G0ozC6wHL5UEjWTFMbWAzgh9t5 3N2VjMzG0h+DncmIo/BDzOOZiwPa/I/F44Bln1tasHvO8sfwovHOnDYv7U8Ao9OdAnQ3 ZaPwRn/o1BDo9WGlcAEuDNEK82Tc4W/r/ThqI+YDySKIJQSgfVzuTeOkEQHAW3bUrFfD g3gZ+AMHc8OBX5rwrIs/1jxRufwwtbTqylWDmxNI0Q5hZk9wToHwDDzs/5BHMOELixt3 Iz1Q== 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=jXKsk3eYzmnutVVhqs5vgBT/FnFX9tZP8AvnUx4lCXQ=; b=yHfSXgaIEvrI5W0XDzDv33+/6qhvpeE5ZPxLA1wekBoy6L4J0iHVGr/QADag/H8tb7 dQqgFjimtG2gq/V5dEbE2it9C/o+M27YA+dZvQNirfizElMA8o7m305U5B5c0sccZqz1 SmGVLbhc8pBEoYPdZJZKYirAsqpKyWy1s0wPtTl+ScP+0Gw0bd1dMLCvSCX7CxLWl94y 3hDiAO6IxFyGOnepVmRES0Tbi9yyHR7jDP04wSBgfZLW/qR3dkpDdvXdoWA7ASb7koVx 6T02F4rHcewh84vpYZ9HQ3XW9pw20Fpj1gGGG+Ybosx8I0uVCfJWFX7/Nj8pYUWHJv1M pTjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oXDCeyyf; 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 p16si31191709oto.287.2020.01.02.15.07.18; Thu, 02 Jan 2020 15:07:30 -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=oXDCeyyf; 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 S1729011AbgABWVf (ORCPT + 99 others); Thu, 2 Jan 2020 17:21:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:40658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728612AbgABWVa (ORCPT ); Thu, 2 Jan 2020 17:21:30 -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 3676124125; Thu, 2 Jan 2020 22:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003689; bh=m8NzCf4h3abOp3hDf9o8iWYgiZUZgDJEXB9aJ8CE73k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXDCeyyfP4sunWqxOVSo8UVt1u7vJRmb2vWHwqpyT5Av4KBH2zdfRsoZkzot1Zn3w M/XEfyR1PX7p3FOPOPqOjRtNpk3TSVityU1MEFaQ1dwmwv0nzaE9sFuesioP6pA3ZR gwZGbMpDJbzhJzZpz9d/8F6wl+D6q7SHinAmo4cU= 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 4.19 050/114] HID: rmi: Check that the RMI_STARTED bit is set before unregistering the RMI transport device Date: Thu, 2 Jan 2020 23:07:02 +0100 Message-Id: <20200102220034.117368636@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@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 9e33165250a3..a5b6b2be9cda 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -737,7 +737,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