HID: lenovo: Check hid_get_drvdata() returns non NULL in lenovo_event()
[ Upstream commit34348a8661] 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:bc04b37ea0("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
5ccdc6dd62
commit
9b14027e4c
1 changed files with 3 additions and 0 deletions
|
|
@ -508,6 +508,9 @@ static int lenovo_event_cptkbd(struct hid_device *hdev,
|
|||
static int lenovo_event(struct hid_device *hdev, struct hid_field *field,
|
||||
struct hid_usage *usage, __s32 value)
|
||||
{
|
||||
if (!hid_get_drvdata(hdev))
|
||||
return 0;
|
||||
|
||||
switch (hdev->product) {
|
||||
case USB_DEVICE_ID_LENOVO_CUSBKBD:
|
||||
case USB_DEVICE_ID_LENOVO_CBTKBD:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue