hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/hid/hid-betopff.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Force feedback support for Betop based devices
34 *
....@@ -19,10 +20,6 @@
1920 */
2021
2122 /*
22
- * This program is free software; you can redistribute it and/or modify it
23
- * under the terms of the GNU General Public License as published by the Free
24
- * Software Foundation; either version 2 of the License, or (at your option)
25
- * any later version.
2623 */
2724
2825
....@@ -63,7 +60,6 @@
6360 struct list_head *report_list =
6461 &hid->report_enum[HID_OUTPUT_REPORT].report_list;
6562 struct input_dev *dev;
66
- int field_count = 0;
6763 int error;
6864 int i, j;
6965
....@@ -89,17 +85,19 @@
8985 * -----------------------------------------
9086 * Do init them with default value.
9187 */
88
+ if (report->maxfield < 4) {
89
+ hid_err(hid, "not enough fields in the report: %d\n",
90
+ report->maxfield);
91
+ return -ENODEV;
92
+ }
9293 for (i = 0; i < report->maxfield; i++) {
94
+ if (report->field[i]->report_count < 1) {
95
+ hid_err(hid, "no values in the field\n");
96
+ return -ENODEV;
97
+ }
9398 for (j = 0; j < report->field[i]->report_count; j++) {
9499 report->field[i]->value[j] = 0x00;
95
- field_count++;
96100 }
97
- }
98
-
99
- if (field_count < 4) {
100
- hid_err(hid, "not enough fields in the report: %d\n",
101
- field_count);
102
- return -ENODEV;
103101 }
104102
105103 betopff = kzalloc(sizeof(*betopff), GFP_KERNEL);