Skip to content

Commit 4fb1251

Browse files
JoseExpositoJiri Kosina
authored andcommitted
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent a4b4940 commit 4fb1251

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/hid/hid-magicmouse.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,10 @@ static int magicmouse_probe(struct hid_device *hdev,
779779
static void magicmouse_remove(struct hid_device *hdev)
780780
{
781781
struct magicmouse_sc *msc = hid_get_drvdata(hdev);
782-
cancel_delayed_work_sync(&msc->work);
782+
783+
if (msc)
784+
cancel_delayed_work_sync(&msc->work);
785+
783786
hid_hw_stop(hdev);
784787
}
785788

0 commit comments

Comments
 (0)