diff options
-rw-r--r-- | drivers/hid/hid-logitech-hidpp.c | 10 |
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 | } |