Skip to content

Commit d1e485f

Browse files
keestoddpoynor
authored andcommitted
HID: provide a helper for validating hid reports
Many drivers need to validate the characteristics of their HID report during initialization to avoid misusing the reports. This adds a common helper to perform validation of the report exisitng, the field existing, and the expected number of values within the field. Change-Id: I572af2301180ba9b260112e147ae80149f39e6a3 Signed-off-by: Kees Cook <keescook@chromium.org> Cc: stable@vger.kernel.org Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent bf810cf commit d1e485f

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

drivers/hid/hid-core.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -796,17 +796,7 @@ struct hid_report *hid_validate_values(struct hid_device *hid,
796796
* ->numbered being checked, which may not always be the case when
797797
* drivers go to access report values.
798798
*/
799-
if (id == 0) {
800-
/*
801-
* Validating on id 0 means we should examine the first
802-
* report in the list.
803-
*/
804-
report = list_entry(
805-
hid->report_enum[type].report_list.next,
806-
struct hid_report, list);
807-
} else {
808-
report = hid->report_enum[type].report_id_hash[id];
809-
}
799+
report = hid->report_enum[type].report_id_hash[id];
810800
if (!report) {
811801
hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
812802
return NULL;

0 commit comments

Comments
 (0)