mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
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 <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
This commit is contained in:
parent
02cc097e62
commit
1430ee73b5
1 changed files with 8 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue