Skip to content

Commit 24d7a5e

Browse files
oneukumZile995
authored andcommitted
HID: holtek: test for sanity of intfdata
commit 01ec0a5 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: Oliver Neukum <oneukum@suse.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I310bc75e9b41a1bdbc10eac36083ded7a4cc6f2b
1 parent 6fa6586 commit 24d7a5e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/hid/hid-holtek-kbd.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,
126126

127127
/* Locate the boot interface, to receive the LED change events */
128128
struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0);
129+
struct hid_device *boot_hid;
130+
struct hid_input *boot_hid_input;
129131

130-
struct hid_device *boot_hid = usb_get_intfdata(boot_interface);
131-
struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs,
132+
if (unlikely(boot_interface == NULL))
133+
return -ENODEV;
134+
135+
boot_hid = usb_get_intfdata(boot_interface);
136+
boot_hid_input = list_first_entry(&boot_hid->inputs,
132137
struct hid_input, list);
133138

134139
return boot_hid_input->input->event(boot_hid_input->input, type, code,

0 commit comments

Comments
 (0)