]> Git Repo - J-linux.git/commitdiff
HID: magicmouse: fix NULL-deref on disconnect
authorJohan Hovold <[email protected]>
Mon, 17 May 2021 10:04:30 +0000 (12:04 +0200)
committerJiri Kosina <[email protected]>
Thu, 27 May 2021 13:40:35 +0000 (15:40 +0200)
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: [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]>
drivers/hid/hid-magicmouse.c

index 097870e43cfe890cd82793a365567383cafde116..8bcaee4ccae0325a2c114d1811a5653d81169147 100644 (file)
@@ -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) {
This page took 0.049189 seconds and 4 git commands to generate.