From 3a034a7a7d61c30809255c1fc27d47d52c8c1bb6 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 11 Dec 2014 13:51:19 +0100 Subject: [PATCH] HID: logitech-hidpp: add boundary check for name retrieval The HID response has a limited size. Do not trust the value returned by hardware, check that it really fits in the message. Signed-off-by: Peter Wu Reviewed-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- drivers/hid/hid-logitech-hidpp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 4d72c20fa233..4292cc33c119 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -313,6 +313,9 @@ static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev) len = response.rap.params[1]; + if (2 + len > sizeof(response.rap.params)) + return NULL; + name = kzalloc(len + 1, GFP_KERNEL); if (!name) return NULL; -- 2.20.1