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) if (!name) return NULL; - while (index < __name_length) - index += hidpp_devicenametype_get_device_name(hidpp, + while (index < __name_length) { + ret = hidpp_devicenametype_get_device_name(hidpp, feature_index, index, name + index, __name_length - index); + if (ret <= 0) { + kfree(name); + return NULL; + } + index += ret; + } return name; } |