Skip to content

Commit f486d9d

Browse files
LekensteynJiri Kosina
authored andcommitted
HID: logitech-hidpp: disable io in probe error path
Balance a hid_device_io_start() call with hid_device_io_stop() in the error path. This avoids processing of HID reports when the probe fails which possibly leads to invalid memory access in hid_device_probe() as report_enum->report_id_hash might already be freed via hid_close_report(). hid_set_drvdata() is called before wtp_allocate, be consistent and clear drvdata too on the error path of wtp_allocate. Signed-off-by: Peter Wu <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 3a034a7 commit f486d9d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
11211121
if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
11221122
ret = wtp_allocate(hdev, id);
11231123
if (ret)
1124-
return ret;
1124+
goto wtp_allocate_fail;
11251125
}
11261126

11271127
INIT_WORK(&hidpp->work, delayed_work_cb);
@@ -1141,6 +1141,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
11411141
if (id->group != HID_GROUP_LOGITECH_DJ_DEVICE) {
11421142
if (!connected) {
11431143
hid_err(hdev, "Device not connected");
1144+
hid_device_io_stop(hdev);
11441145
goto hid_parse_fail;
11451146
}
11461147

@@ -1186,6 +1187,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
11861187
hid_parse_fail:
11871188
cancel_work_sync(&hidpp->work);
11881189
mutex_destroy(&hidpp->send_mutex);
1190+
wtp_allocate_fail:
11891191
hid_set_drvdata(hdev, NULL);
11901192
return ret;
11911193
}

0 commit comments

Comments
 (0)