Commit fc3abb53 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull HID fixes from Jiri Kosina:

 - data sanitization and validtion fixes for report descriptor parser
   from Marc Zyngier

 - memory leak fix for hid-elan driver from Dinghao Liu

 - two device-specific quirks

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
  HID: core: Sanitize event code and type when mapping input
  HID: core: Correctly handle ReportSize being zero
  HID: elan: Fix memleak in elan_input_configured
  HID: microsoft: Add rumble support for the 8bitdo SN30 Pro+ controller
  HID: quirks: Set INCREMENT_USAGE_ON_DUPLICATE for all Saitek X52 devices
parents c3a13095 35556bed
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1597,6 +1597,17 @@ static void hid_output_field(const struct hid_device *hid,
	}
}

/*
 * Compute the size of a report.
 */
static size_t hid_compute_report_size(struct hid_report *report)
{
	if (report->size)
		return ((report->size - 1) >> 3) + 1;

	return 0;
}

/*
 * Create a report. 'data' has to be allocated using
 * hid_alloc_report_buf() so that it has proper size.
@@ -1609,7 +1620,7 @@ void hid_output_report(struct hid_report *report, __u8 *data)
	if (report->id > 0)
		*data++ = report->id;

	memset(data, 0, ((report->size - 1) >> 3) + 1);
	memset(data, 0, hid_compute_report_size(report));
	for (n = 0; n < report->maxfield; n++)
		hid_output_field(report->device, report->field[n], data);
}
@@ -1739,7 +1750,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,
		csize--;
	}

	rsize = ((report->size - 1) >> 3) + 1;
	rsize = hid_compute_report_size(report);

	if (report_enum->numbered && rsize >= HID_MAX_BUFFER_SIZE)
		rsize = HID_MAX_BUFFER_SIZE - 1;
+2 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
	ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER);
	if (ret) {
		hid_err(hdev, "Failed to init elan MT slots: %d\n", ret);
		input_free_device(input);
		return ret;
	}

@@ -198,6 +199,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
	if (ret) {
		hid_err(hdev, "Failed to register elan input device: %d\n",
			ret);
		input_mt_destroy_slots(input);
		input_free_device(input);
		return ret;
	}
+3 −0
Original line number Diff line number Diff line
@@ -850,6 +850,7 @@
#define USB_DEVICE_ID_MS_POWER_COVER     0x07da
#define USB_DEVICE_ID_MS_XBOX_ONE_S_CONTROLLER	0x02fd
#define USB_DEVICE_ID_MS_PIXART_MOUSE    0x00cb
#define USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS      0x02e0

#define USB_VENDOR_ID_MOJO		0x8282
#define USB_DEVICE_ID_RETRO_ADAPTER	0x3201
@@ -1015,6 +1016,8 @@
#define USB_DEVICE_ID_SAITEK_RAT9	0x0cfa
#define USB_DEVICE_ID_SAITEK_MMO7	0x0cd0
#define USB_DEVICE_ID_SAITEK_X52	0x075c
#define USB_DEVICE_ID_SAITEK_X52_2	0x0255
#define USB_DEVICE_ID_SAITEK_X52_PRO	0x0762

#define USB_VENDOR_ID_SAMSUNG		0x0419
#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE	0x0001
+4 −0
Original line number Diff line number Diff line
@@ -1132,6 +1132,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
	}

mapped:
	/* Mapping failed, bail out */
	if (!bit)
		return;

	if (device->driver->input_mapped &&
	    device->driver->input_mapped(device, hidinput, field, usage,
					 &bit, &max) < 0) {
+2 −0
Original line number Diff line number Diff line
@@ -448,6 +448,8 @@ static const struct hid_device_id ms_devices[] = {
		.driver_data = MS_SURFACE_DIAL },
	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_XBOX_ONE_S_CONTROLLER),
		.driver_data = MS_QUIRK_FF },
	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS),
		.driver_data = MS_QUIRK_FF },
	{ }
};
MODULE_DEVICE_TABLE(hid, ms_devices);
Loading