Unverified Commit 3191c9e4 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!15784 HID: betop: check shape of output reports

parents 74c40b7b a18404fc
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ static int betopff_init(struct hid_device *hid)
	struct list_head *report_list =
			&hid->report_enum[HID_OUTPUT_REPORT].report_list;
	struct input_dev *dev;
	int field_count = 0;
	int error;
	int i, j;

@@ -89,19 +88,21 @@ static int betopff_init(struct hid_device *hid)
	 * -----------------------------------------
	 * Do init them with default value.
	 */
	if (report->maxfield < 4) {
		hid_err(hid, "not enough fields in the report: %d\n",
				report->maxfield);
		return -ENODEV;
	}
	for (i = 0; i < report->maxfield; i++) {
		if (report->field[i]->report_count < 1) {
			hid_err(hid, "no values in the field\n");
			return -ENODEV;
		}
		for (j = 0; j < report->field[i]->report_count; j++) {
			report->field[i]->value[j] = 0x00;
			field_count++;
		}
	}

	if (field_count < 4) {
		hid_err(hid, "not enough fields in the report: %d\n",
				field_count);
		return -ENODEV;
	}

	betopff = kzalloc(sizeof(*betopff), GFP_KERNEL);
	if (!betopff)
		return -ENOMEM;