Message ID | 20190725131333.26192-1-oneukum@suse.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Jiri Kosina |
Headers | show |
Series | holtek: test for sanity of intfdata | expand |
On Thu, 25 Jul 2019, Oliver Neukum wrote: > 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. > > Reported-by: syzbot+965152643a75a56737be@syzkaller.appspotmail.com > Signed-off-by: Oliver Neukum <oneukum@suse.com> Applied, thanks Oliver.
diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c index b3d502421b79..67ce75dfa9a4 100644 --- a/drivers/hid/hid-holtek-kbd.c +++ b/drivers/hid/hid-holtek-kbd.c @@ -123,9 +123,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type, /* Locate the boot interface, to receive the LED change events */ struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0); - - struct hid_device *boot_hid = usb_get_intfdata(boot_interface); - struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs, + struct hid_device *boot_hid; + struct hid_input *boot_hid_input; + + if (unlikely(boot_interface == NULL)) + return -ENODEV; + + boot_hid = usb_get_intfdata(boot_interface); + boot_hid_input = list_first_entry(&boot_hid->inputs, struct hid_input, list); return boot_hid_input->input->event(boot_hid_input->input, type, code,
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. Reported-by: syzbot+965152643a75a56737be@syzkaller.appspotmail.com Signed-off-by: Oliver Neukum <oneukum@suse.com> --- drivers/hid/hid-holtek-kbd.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)