From: Andrew Duggan <hidden> Date: 2014-07-17 23:22:36
It is possible that the hid-rmi driver could get loaded onto a device which does not have the
expected report ids. This should not happen because it would indicate that the hid-rmi driver is
not compatible with that device. However, if it does happen it should return an error from probe
instead of dereferencing a null pointer.
related bug:
https://bugzilla.kernel.org/show_bug.cgi?id=80091
Signed-off-by: Andrew Duggan <redacted>
---
Added hid_err messages as suggested by Benjamin. This fixes the null pointer dereference from
bug 80091 while the next patch addresses the binding issue in hid-core.
drivers/hid/hid-rmi.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
@@ -866,12 +868,26 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)returnret;}-data->input_report_size=(hdev->report_enum[HID_INPUT_REPORT]-.report_id_hash[RMI_ATTN_REPORT_ID]->size>>3)-+1/* report id */;-data->output_report_size=(hdev->report_enum[HID_OUTPUT_REPORT]-.report_id_hash[RMI_WRITE_REPORT_ID]->size>>3)-+1/* report id */;+input_report=hdev->report_enum[HID_INPUT_REPORT]+.report_id_hash[RMI_ATTN_REPORT_ID];+if(!input_report){+hid_err(hdev,"device does not have expected input report\n");+ret=-ENODEV;+returnret;+}++data->input_report_size=(input_report->size>>3)+1/* report id */;++output_report=hdev->report_enum[HID_OUTPUT_REPORT]+.report_id_hash[RMI_WRITE_REPORT_ID];+if(!output_report){+hid_err(hdev,"device does not have expected output report\n");+ret=-ENODEV;+returnret;+}++data->output_report_size=(output_report->size>>3)++1/* report id */;alloc_size=data->output_report_size+data->input_report_size;
From: Andrew Duggan <hidden> Date: 2014-07-17 23:22:39
On composite HID devices there may be multiple HID devices on separate interfaces, but hid-rmi
should only bind to the mouse interface. One example is the Dell Venue 11 Pro's keyboard dock
which contains a composite USB device with a HID touchpad and HID keyboard on separate intefaces.
Since the USB Vendor ID is Synaptic's, hid-core is currently trying to bind hid-rmi to all\of
the HID devices. This patch ensures that hid-rmi only binds to the mouse interface.
related bug:
https://bugzilla.kernel.org/show_bug.cgi?id=80091
Signed-off-by: Andrew Duggan <redacted>
---
drivers/hid/hid-core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -783,7 +783,9 @@ static int hid_scan_report(struct hid_device *hid)*Vendorspecifichandlings*/if((hid->vendor==USB_VENDOR_ID_SYNAPTICS)&&-(hid->group==HID_GROUP_GENERIC))+(hid->group==HID_GROUP_GENERIC)&&+/* only bind to the mouse interface of composite USB devices */+(hid->bus!=BUS_USB||hid->type==HID_TYPE_USBMOUSE))/* hid-rmi should take care of them, not hid-generic */hid->group=HID_GROUP_RMI;
From: Benjamin Tissoires <hidden> Date: 2014-07-18 13:07:16
On Jul 17 2014 or thereabouts, Andrew Duggan wrote:
On composite HID devices there may be multiple HID devices on separate interfaces, but hid-rmi
should only bind to the mouse interface. One example is the Dell Venue 11 Pro's keyboard dock
which contains a composite USB device with a HID touchpad and HID keyboard on separate intefaces.
Since the USB Vendor ID is Synaptic's, hid-core is currently trying to bind hid-rmi to all\of
the HID devices. This patch ensures that hid-rmi only binds to the mouse interface.
related bug:
https://bugzilla.kernel.org/show_bug.cgi?id=80091
Signed-off-by: Andrew Duggan <redacted>
---
As mentioned in a private mail, Andrew told me that for now, each
touchpad using hid-rmi he has seen are using the boot mouse protocol, so
this patch will give us some space and will not break existing current
setups.
Reviewed-by: Benjamin Tissoires <redacted>
Cheers,
Benjamin
@@ -783,7 +783,9 @@ static int hid_scan_report(struct hid_device *hid)*Vendorspecifichandlings*/if((hid->vendor==USB_VENDOR_ID_SYNAPTICS)&&-(hid->group==HID_GROUP_GENERIC))+(hid->group==HID_GROUP_GENERIC)&&+/* only bind to the mouse interface of composite USB devices */+(hid->bus!=BUS_USB||hid->type==HID_TYPE_USBMOUSE))/* hid-rmi should take care of them, not hid-generic */hid->group=HID_GROUP_RMI;
On composite HID devices there may be multiple HID devices on separate interfaces, but hid-rmi
should only bind to the mouse interface. One example is the Dell Venue 11 Pro's keyboard dock
which contains a composite USB device with a HID touchpad and HID keyboard on separate intefaces.
Since the USB Vendor ID is Synaptic's, hid-core is currently trying to bind hid-rmi to all\of
the HID devices. This patch ensures that hid-rmi only binds to the mouse interface.
related bug:
https://bugzilla.kernel.org/show_bug.cgi?id=80091
Signed-off-by: Andrew Duggan <redacted>
From: Benjamin Tissoires <hidden> Date: 2014-07-18 13:04:25
On Jul 17 2014 or thereabouts, Andrew Duggan wrote:
It is possible that the hid-rmi driver could get loaded onto a device which does not have the
expected report ids. This should not happen because it would indicate that the hid-rmi driver is
not compatible with that device. However, if it does happen it should return an error from probe
instead of dereferencing a null pointer.
related bug:
https://bugzilla.kernel.org/show_bug.cgi?id=80091
Signed-off-by: Andrew Duggan <redacted>
---
Added hid_err messages as suggested by Benjamin. This fixes the null pointer dereference from
bug 80091 while the next patch addresses the binding issue in hid-core.
Reviewed-by: Benjamin Tissoires <redacted>
Cheers,
Benjamin
@@ -866,12 +868,26 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)returnret;}-data->input_report_size=(hdev->report_enum[HID_INPUT_REPORT]-.report_id_hash[RMI_ATTN_REPORT_ID]->size>>3)-+1/* report id */;-data->output_report_size=(hdev->report_enum[HID_OUTPUT_REPORT]-.report_id_hash[RMI_WRITE_REPORT_ID]->size>>3)-+1/* report id */;+input_report=hdev->report_enum[HID_INPUT_REPORT]+.report_id_hash[RMI_ATTN_REPORT_ID];+if(!input_report){+hid_err(hdev,"device does not have expected input report\n");+ret=-ENODEV;+returnret;+}++data->input_report_size=(input_report->size>>3)+1/* report id */;++output_report=hdev->report_enum[HID_OUTPUT_REPORT]+.report_id_hash[RMI_WRITE_REPORT_ID];+if(!output_report){+hid_err(hdev,"device does not have expected output report\n");+ret=-ENODEV;+returnret;+}++data->output_report_size=(output_report->size>>3)++1/* report id */;alloc_size=data->output_report_size+data->input_report_size;
It is possible that the hid-rmi driver could get loaded onto a device which does not have the
expected report ids. This should not happen because it would indicate that the hid-rmi driver is
not compatible with that device. However, if it does happen it should return an error from probe
instead of dereferencing a null pointer.
related bug:
https://bugzilla.kernel.org/show_bug.cgi?id=80091
Signed-off-by: Andrew Duggan <redacted>