Skip to contentSkip to conversation

HID: magicmouse: fix NULL-deref on disconnect

PATCH Applied Johan Hovold 2 participants 2 messages May 17, 2021 – May 26, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: magicmouse: fix NULL-deref on disconnect

Commit 9d7b18668956 ("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 9d7b18668956 ("HID: magicmouse: add support for Apple Magic Trackpad 2")
Cc Claudio Mettler <[email protected]>
Cc Marek Wyborski <[email protected]>
Cc Sean O'Brien <[email protected]>
---
 drivers/hid/hid-magicmouse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-magicmouse.c +1 -1
index 2bb473d8c424..56dda50aa3d8 100644
@@ -693,7 +693,7 @@ static int magicmouse_probe(struct hid_device *hdev,
 	if (id->vendor == USB_VENDOR_ID_APPLE &&
 	    id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
 	    hdev->type != HID_TYPE_USBMOUSE)
-		return 0;
+		return -ENODEV;
 
 	msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL);
 	if (msc == NULL) {
Signature · 1 line
2.26.3
maintainer Applied
#1 lore raw
Quoted 6 lines · Johan Hovold

Commit 9d7b18668956 ("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).

Quoted 7 lines
Reported-by [email protected]
Fixes 9d7b18668956 ("HID: magicmouse: add support for Apple Magic Trackpad 2")
Cc Claudio Mettler <[email protected]>
Cc Marek Wyborski <[email protected]>
Cc Sean O'Brien <[email protected]>

Applied, thanks Johan.

Signature · 2 lines
Jiri Kosina
SUSE Labs