Skip to contentSkip to conversation

HID: hid-lg: We only need pseudorandom bytes for the address

RFC PATCH In review George Spelvin 1 participant 1 message Mar 28, 2020 HID

lore
Share & tools
lore
#0 lore raw

RFC PATCH 25/50 HID: hid-lg: We only need pseudorandom bytes for the address

It's just to reduce collisions among cooperating USB HID devices; it's not intended to be secure against a malicious attacker (and it would need to be a lot larger than 16 bits if it were).

Cc Simon Wood <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Jiri Kosina <[email protected]>
Cc Benjamin Tissoires <[email protected]>
---
 drivers/hid/hid-lg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-lg.c +1 -1
index 0dc7cdfc56f77..b6b6ed9834c7c 100644
@@ -832,7 +832,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 			/* Select random Address */
 			buf[1] = 0xB2;
-			get_random_bytes(&buf[2], 2);
+			prandom_bytes(buf+2, 2);
 
 			ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
 					HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
Signature · 1 line
2.26.0