diff options
author | Johan Hovold <johan@kernel.org> | 2021-05-17 12:04:30 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-06-10 13:37:10 +0200 |
commit | 368c5d45a87e1bcc7f1e98e0c255c37b7b12c5d6 (patch) | |
tree | 47dca36f0f250a40359d0a3ef1b9c201297ada7e | |
parent | HID: i2c-hid: Skip ELAN power-on command after reset (diff) | |
download | wireguard-linux-368c5d45a87e1bcc7f1e98e0c255c37b7b12c5d6.tar.xz wireguard-linux-368c5d45a87e1bcc7f1e98e0c255c37b7b12c5d6.zip |
HID: magicmouse: fix NULL-deref on disconnect
commit 4b4f6cecca446abcb686c6e6c451d4f1ec1a7497 upstream.
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: syzbot+ee6f6e2e68886ca256a8@syzkaller.appspotmail.com
Fixes: 9d7b18668956 ("HID: magicmouse: add support for Apple Magic Trackpad 2")
Cc: stable@vger.kernel.org # 4.20
Cc: Claudio Mettler <claudio@ponyfleisch.ch>
Cc: Marek Wyborski <marek.wyborski@emwesoft.com>
Cc: Sean O'Brien <seobrien@chromium.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hid/hid-magicmouse.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index abd86903875f..fc4c07459753 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -597,7 +597,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) { |