Skip to content

Commit 4b4f6ce

Browse files
jhovoldJiri Kosina
authored andcommitted
HID: magicmouse: fix NULL-deref on disconnect
Commit 9d7b186 ("HID: magicmouse: add support for Apple Magic Trackpad 2") added a sanity check for an Apple trackpad but returned success instead of -ENODEV when the check failed. This means that the remove callback will dereference the never-initialised driver data pointer when the driver is later unbound (e.g. on USB disconnect). Reported-by: [email protected] Fixes: 9d7b186 ("HID: magicmouse: add support for Apple Magic Trackpad 2") Cc: [email protected] # 4.20 Cc: Claudio Mettler <[email protected]> Cc: Marek Wyborski <[email protected]> Cc: Sean O'Brien <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 22db5e0 commit 4b4f6ce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hid/hid-magicmouse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static int magicmouse_probe(struct hid_device *hdev,
693693
if (id->vendor == USB_VENDOR_ID_APPLE &&
694694
id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
695695
hdev->type != HID_TYPE_USBMOUSE)
696-
return 0;
696+
return -ENODEV;
697697

698698
msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL);
699699
if (msc == NULL) {

0 commit comments

Comments
 (0)