aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-magicmouse.c
diff options
context:
space:
mode:
authorJosé Expósito <jose.exposito89@gmail.com>2021-05-10 08:22:37 +0200
committerJiri Kosina <jkosina@suse.cz>2021-05-27 15:40:34 +0200
commit4fb125192563670e820991de48f8db495ecc7ff7 (patch)
tree9cbbc7634c0e5873205328fb529938b4b7a94af0 /drivers/hid/hid-magicmouse.c
parentHID: gt683r: add missing MODULE_DEVICE_TABLE (diff)
downloadlinux-dev-4fb125192563670e820991de48f8db495ecc7ff7.tar.xz
linux-dev-4fb125192563670e820991de48f8db495ecc7ff7.zip
HID: magicmouse: fix crash when disconnecting Magic Trackpad 2
When the Apple Magic Trackpad 2 is connected over USB it registers four hid_device report descriptors, however, the driver only handles the one with type HID_TYPE_USBMOUSE and ignores the other three, thus, no driver data is attached to them. When the device is disconnected, the remove callback is called for the four hid_device report descriptors, crashing when the driver data is NULL. Check that the driver data is not NULL before using it in the remove callback. Signed-off-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-magicmouse.c')
-rw-r--r--drivers/hid/hid-magicmouse.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 2bb473d8c424..097870e43cfe 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -779,7 +779,10 @@ err_stop_hw:
static void magicmouse_remove(struct hid_device *hdev)
{
struct magicmouse_sc *msc = hid_get_drvdata(hdev);
- cancel_delayed_work_sync(&msc->work);
+
+ if (msc)
+ cancel_delayed_work_sync(&msc->work);
+
hid_hw_stop(hdev);
}