From: Andrew Duggan <aduggan@synaptics.com>
To: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Andrew Duggan <aduggan@synaptics.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Federico Cerutti <federico@ceres-c.it>,
Christopher Heiny <Cheiny@synaptics.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: [PATCH] HID: rmi: Check that the RMI_STARTED bit is set before unregistering the RMI transport device
Date: Wed, 23 Oct 2019 01:24:03 +0000 [thread overview]
Message-ID: <20191023012344.20998-1-aduggan@synaptics.com> (raw)
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. A subsequent patch in the RMI core will add
checks to validate the pointers before accessing them.
The kernel oops was reported in this message:
https://www.spinics.net/lists/linux-input/msg58433.html
Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Reported-by: Federico Cerutti <federico@ceres-c.it>
---
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
next reply other threads:[~2019-10-23 1:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 1:24 Andrew Duggan [this message]
2019-10-23 1:24 ` [PATCH] Input: synaptics-rmi4 - validate that the rmi_dev pointer is set before dereferencing it Andrew Duggan
2019-10-29 4:19 ` Dmitry Torokhov
2019-10-29 18:40 ` Andrew Duggan
2019-11-15 15:26 ` [PATCH] HID: rmi: Check that the RMI_STARTED bit is set before unregistering the RMI transport device Jiri Kosina
2019-11-15 18:18 ` Andrew Duggan
2019-11-18 9:24 ` Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191023012344.20998-1-aduggan@synaptics.com \
--to=aduggan@synaptics.com \
--cc=Cheiny@synaptics.com \
--cc=benjamin.tissoires@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=federico@ceres-c.it \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).