Commit ff44d3df authored by Oliver Neukum's avatar Oliver Neukum Committed by Khalid Elmously

HID: holtek: test for sanity of intfdata

BugLink: https://bugs.launchpad.net/bugs/1845038

commit 01ec0a5f upstream.

The ioctl handler uses the intfdata of a second interface,
which may not be present in a broken or malicious device, hence
the intfdata needs to be checked for NULL.

[jkosina@suse.cz: fix newly added spurious space]
Reported-by: syzbot+965152643a75a56737be@syzkaller.appspotmail.com
Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 0bdaf56f
...@@ -126,9 +126,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type, ...@@ -126,9 +126,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,
/* Locate the boot interface, to receive the LED change events */ /* Locate the boot interface, to receive the LED change events */
struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0); struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0);
struct hid_device *boot_hid;
struct hid_input *boot_hid_input;
struct hid_device *boot_hid = usb_get_intfdata(boot_interface); if (unlikely(boot_interface == NULL))
struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs, return -ENODEV;
boot_hid = usb_get_intfdata(boot_interface);
boot_hid_input = list_first_entry(&boot_hid->inputs,
struct hid_input, list); struct hid_input, list);
return boot_hid_input->input->event(boot_hid_input->input, type, code, return boot_hid_input->input->event(boot_hid_input->input, type, code,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment