Skip to contentSkip to conversation

hid_parse failure

PATCH Srinivas Pandruvada 1 participant 1 message May 9, 2012 HID

lore
Share & tools
lore
#0 lore raw

Any comments on my patch for hid parsing failure (submitted on May 1st)?

Thanks,
Srinivas

When logical maximum is 0xffffffff, the parser fails even if logical minimum is equal to or greater than 0.
By HID specification, if both the Logical Minimum and Logical Maximum extents are defined as positive values (0 or greater) then the report field can be assumed to be an unsigned value. Otherwise, all integer values are signed values represented in 2’s complement format.

---
 drivers/hid/hid-core.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
drivers/hid/hid-core.c +10 -2
index c757f10..b616f4b 100644
@@ -225,8 +225,16 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
 		return -1;
 	}
 
-	if (parser->global.logical_maximum<  parser->global.logical_minimum) {
-		dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum);
+	if ((parser->global.logical_minimum<  0&&
+		parser->global.logical_maximum<
+			parser->global.logical_minimum) ||
+		(parser->global.logical_minimum>= 0&&
+			(__u32)parser->global.logical_maximum<
+			(__u32)parser->global.logical_minimum)
+		) {
+		dbg_hid("logical range invalid 0x%x 0x%x\n",
+			parser->global.logical_minimum,
+				parser->global.logical_maximum);
 		return -1;
 	}
 
Signature · 6 lines
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html