aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-12-11 07:51:18 -0500
committerJiri Kosina <jkosina@suse.cz>2014-12-11 17:10:00 -0500
commit1430ee73b566a30bc210501d1e0e99c519707f1e (patch)
treeb16d64b16d3f19f4675bc9787719795d1601d96c /drivers/hid
parent02cc097e62d51bf6e5cb4209ca90d9bf68e358b5 (diff)
HID: logitech-hidpp: check name retrieval return code
hidpp_devicenametype_get_device_name() may return a negative value on protocol errors (for example, when the device is powered off). Explicitly check this condition to avoid a long-running loop. (0 cannot be returned as __name_length - index > 0, but check for it anyway as it would otherwise result in an infinite loop.) 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.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 5066df8afee5..4d72c20fa233 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -484,10 +484,16 @@ static char *hidpp_get_device_name(struct hidpp_device *hidpp)
484 if (!name) 484 if (!name)
485 return NULL; 485 return NULL;
486 486
487 while (index < __name_length) 487 while (index < __name_length) {
488 index += hidpp_devicenametype_get_device_name(hidpp, 488 ret = hidpp_devicenametype_get_device_name(hidpp,
489 feature_index, index, name + index, 489 feature_index, index, name + index,
490 __name_length - index); 490 __name_length - index);
491 if (ret <= 0) {
492 kfree(name);
493 return NULL;
494 }
495 index += ret;
496 }
491 497
492 return name; 498 return name;
493} 499}