Skip to content

Commit 720ac46

Browse files
gregkhbentiss
authored andcommitted
HID: wacom: fix problems when device is not a valid USB device
The wacom driver accepts devices of more than just USB types, but some code paths can cause problems if the device being controlled is not a USB device due to a lack of checking. Add the needed checks to ensure that the USB device accesses are only happening on a "real" USB device, and not one on some other bus. Cc: Jiri Kosina <[email protected]> Cc: Benjamin Tissoires <[email protected]> Cc: [email protected] Cc: [email protected] Tested-by: Benjamin Tissoires <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f83baa0 commit 720ac46

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/hid/wacom_sys.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
726726
* Skip the query for this type and modify defaults based on
727727
* interface number.
728728
*/
729-
if (features->type == WIRELESS) {
729+
if (features->type == WIRELESS && intf) {
730730
if (intf->cur_altsetting->desc.bInterfaceNumber == 0)
731731
features->device_type = WACOM_DEVICETYPE_WL_MONITOR;
732732
else
@@ -2451,6 +2451,9 @@ static void wacom_wireless_work(struct work_struct *work)
24512451

24522452
wacom_destroy_battery(wacom);
24532453

2454+
if (!usbdev)
2455+
return;
2456+
24542457
/* Stylus interface */
24552458
hdev1 = usb_get_intfdata(usbdev->config->interface[1]);
24562459
wacom1 = hid_get_drvdata(hdev1);
@@ -2730,8 +2733,6 @@ static void wacom_mode_change_work(struct work_struct *work)
27302733
static int wacom_probe(struct hid_device *hdev,
27312734
const struct hid_device_id *id)
27322735
{
2733-
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
2734-
struct usb_device *dev = interface_to_usbdev(intf);
27352736
struct wacom *wacom;
27362737
struct wacom_wac *wacom_wac;
27372738
struct wacom_features *features;
@@ -2766,8 +2767,14 @@ static int wacom_probe(struct hid_device *hdev,
27662767
wacom_wac->hid_data.inputmode = -1;
27672768
wacom_wac->mode_report = -1;
27682769

2769-
wacom->usbdev = dev;
2770-
wacom->intf = intf;
2770+
if (hid_is_usb(hdev)) {
2771+
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
2772+
struct usb_device *dev = interface_to_usbdev(intf);
2773+
2774+
wacom->usbdev = dev;
2775+
wacom->intf = intf;
2776+
}
2777+
27712778
mutex_init(&wacom->lock);
27722779
INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
27732780
INIT_WORK(&wacom->wireless_work, wacom_wireless_work);

0 commit comments

Comments
 (0)