Skip to content

Commit 8725aa4

Browse files
aduggan-synaJiri Kosina
authored andcommitted
HID: rmi: Check that the RMI_STARTED bit is set before unregistering the RMI transport device
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 [[email protected]: reworded changelog as agreed with Andrew] Signed-off-by: Andrew Duggan <[email protected]> Reported-by: Federico Cerutti <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent fd70466 commit 8725aa4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/hid/hid-rmi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,8 @@ static void rmi_remove(struct hid_device *hdev)
744744
{
745745
struct rmi_data *hdata = hid_get_drvdata(hdev);
746746

747-
if (hdata->device_flags & RMI_DEVICE) {
747+
if ((hdata->device_flags & RMI_DEVICE)
748+
&& test_bit(RMI_STARTED, &hdata->flags)) {
748749
clear_bit(RMI_STARTED, &hdata->flags);
749750
cancel_work_sync(&hdata->reset_work);
750751
rmi_unregister_transport_device(&hdata->xport);

0 commit comments

Comments
 (0)