Skip to contentSkip to conversation

HID: prodikeys: Check presence of pm->input_ep82

PATCH Applied Günther Noack 2 participants 2 messages Jan 9 – Jan 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: prodikeys: Check presence of pm->input_ep82

Fake USB devices can send their own report descriptors for which the input_mapping() hook does not get called. In this case, pm->input_ep82 stays NULL, which leads to a crash later.

This does not happen with the real device, but can be provoked by imposing as one.

---
 drivers/hid/hid-prodikeys.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hid/hid-prodikeys.c +4 -0
index 74bddb2c3e82..6e413df38358 100644
@@ -378,6 +378,10 @@ static int pcmidi_handle_report4(struct pcmidi_snd *pm, u8 *data)
 	bit_mask = (bit_mask << 8) | data[2];
 	bit_mask = (bit_mask << 8) | data[3];
 
+	/* robustness in case input_mapping hook does not get called */
+	if (!pm->input_ep82)
+		return 0;
+
 	/* break keys */
 	for (bit_index = 0; bit_index < 24; bit_index++) {
 		if (!((0x01 << bit_index) & bit_mask)) {
Signature · 1 line
2.52.0.457.g6b5491de43-goog
maintainer Applied
#1 lore raw
Quoted 6 lines · Günther Noack

Fake USB devices can send their own report descriptors for which the input_mapping() hook does not get called. In this case, pm->input_ep82 sta= ys NULL, which leads to a crash later.

This does not happen with the real device, but can be provoked by imposing = as one.

Applied. thanks.

Signature · 2 lines
Jiri Kosina
SUSE Labs