aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-12-11 07:51:19 -0500
committerJiri Kosina <jkosina@suse.cz>2014-12-11 17:10:00 -0500
commit3a034a7a7d61c30809255c1fc27d47d52c8c1bb6 (patch)
tree0d86115c4a291314da2f6ddb52521cba9c782d43 /drivers/hid
parent1430ee73b566a30bc210501d1e0e99c519707f1e (diff)
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 <peter@lekensteyn.nl> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-logitech-hidpp.c3
1 files changed, 3 insertions, 0 deletions
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)
313 313
314 len = response.rap.params[1]; 314 len = response.rap.params[1];
315 315
316 if (2 + len > sizeof(response.rap.params))
317 return NULL;
318
316 name = kzalloc(len + 1, GFP_KERNEL); 319 name = kzalloc(len + 1, GFP_KERNEL);
317 if (!name) 320 if (!name)
318 return NULL; 321 return NULL;