Skip to content

Commit 34348a8

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
HID: lenovo: Check hid_get_drvdata() returns non NULL in lenovo_event()
The HID lenovo probe function only attaches drvdata to one of the USB interfaces, but lenovo_event() will get called for all USB interfaces to which hid-lenovo is bound. This allows a malicious device to fake being a device handled by hid-lenovo, which generates events for which lenovo_event() has special handling (and thus dereferences hid_get_drvdata()) on another interface triggering a NULL pointer exception. Add a check for hid_get_drvdata() returning NULL, avoiding this possible NULL pointer exception. Fixes: bc04b37 ("HID: lenovo: Add ThinkPad 10 Ultrabook Keyboard support") Reviewed-by: Marek Behún <kabel@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 658d04e commit 34348a8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/hid/hid-lenovo.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ static int lenovo_event_cptkbd(struct hid_device *hdev,
508508
static int lenovo_event(struct hid_device *hdev, struct hid_field *field,
509509
struct hid_usage *usage, __s32 value)
510510
{
511+
if (!hid_get_drvdata(hdev))
512+
return 0;
513+
511514
switch (hdev->product) {
512515
case USB_DEVICE_ID_LENOVO_CUSBKBD:
513516
case USB_DEVICE_ID_LENOVO_CBTKBD:

0 commit comments

Comments
 (0)