Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61c6111f authored by Lee Jones's avatar Lee Jones Committed by Srinivasarao Pathipati
Browse files

ANDROID: HID: Only utilise UHID provided exports if UHID is enabled



Commit "ANDROID: HID; Over-ride default maximum buffer size when using
UHID" provided a means for the UHID driver to offer an alternative
(smaller) report buffer size when dealing with user-space.  The method
used was an Android-only solution designed to prevent the KMI ABI from
being broken (nb: the upstream solution was cleaner, but broke the ABI).

Since this solution involved consuming resources exported by a
subordinate driver, that driver would have to be enabled for the export
to take place.  Since all of our default configs enable UHID, an issue
was not detected.  However, for more specific kernel configs, where HID
is enabled, but UHID is not, this leads to compile-time undefined symbol
errors:

  ld.lld: error: undefined symbol: uhid_hid_driver

This patch relies on the compiler to leave out unutilised sections of
the code if the associated resources are not available.

Bug: 260007429
Reported-by: default avatarPaul Lawrence <paullawrence@google.com>
Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: I80b1aa7454c89d5c5e21f0268252ffb666efab97
Signed-off-by: default avatarLee Jones <joneslee@google.com>
parent e699d543
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
	offset = report->size;
	report->size += parser->global.report_size * parser->global.report_count;

	if (parser->device->ll_driver == &uhid_hid_driver)
	if (IS_ENABLED(CONFIG_UHID) && parser->device->ll_driver == &uhid_hid_driver)
		max_buffer_size = UHID_DATA_MAX;

	/* Total size check: Allow for possible report index byte */
@@ -1767,7 +1767,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,

	rsize = hid_compute_report_size(report);

	if (hid->ll_driver == &uhid_hid_driver)
	if (IS_ENABLED(CONFIG_UHID) && hid->ll_driver == &uhid_hid_driver)
		max_buffer_size = UHID_DATA_MAX;

	if (report_enum->numbered && rsize >= max_buffer_size)