Skip to content

Commit 889c391

Browse files
committed
HID: wacom: fix problems when device is not a valid USB device
commit 720ac46 upstream. 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 <jikos@kernel.org> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: linux-input@vger.kernel.org Cc: stable@vger.kernel.org Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20211201183503.2373082-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6272b17 commit 889c391

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎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
@@ -2448,6 +2448,9 @@ static void wacom_wireless_work(struct work_struct *work)
24482448

24492449
wacom_destroy_battery(wacom);
24502450

2451+
if (!usbdev)
2452+
return;
2453+
24512454
/* Stylus interface */
24522455
hdev1 = usb_get_intfdata(usbdev->config->interface[1]);
24532456
wacom1 = hid_get_drvdata(hdev1);
@@ -2727,8 +2730,6 @@ static void wacom_mode_change_work(struct work_struct *work)
27272730
static int wacom_probe(struct hid_device *hdev,
27282731
const struct hid_device_id *id)
27292732
{
2730-
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
2731-
struct usb_device *dev = interface_to_usbdev(intf);
27322733
struct wacom *wacom;
27332734
struct wacom_wac *wacom_wac;
27342735
struct wacom_features *features;
@@ -2763,8 +2764,14 @@ static int wacom_probe(struct hid_device *hdev,
27632764
wacom_wac->hid_data.inputmode = -1;
27642765
wacom_wac->mode_report = -1;
27652766

2766-
wacom->usbdev = dev;
2767-
wacom->intf = intf;
2767+
if (hid_is_usb(hdev)) {
2768+
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
2769+
struct usb_device *dev = interface_to_usbdev(intf);
2770+
2771+
wacom->usbdev = dev;
2772+
wacom->intf = intf;
2773+
}
2774+
27682775
mutex_init(&wacom->lock);
27692776
INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
27702777
INIT_WORK(&wacom->wireless_work, wacom_wireless_work);

0 commit comments

Comments
 (0)