HID: logitech-hidpp: ignore very-short or empty names
authorHans de Goede <hdegoede@redhat.com>
Sat, 20 Apr 2019 11:22:06 +0000 (13:22 +0200)
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>
Tue, 23 Apr 2019 16:02:43 +0000 (18:02 +0200)
Some devices report an empty or very short name, in this case stick
with the name generated by the logitech-dj code instead of overriding it
with e.g. "Logitech ".

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
drivers/hid/hid-logitech-hidpp.c

index b389fcc..e7f0823 100644 (file)
@@ -741,6 +741,9 @@ static char *hidpp_unifying_get_name(struct hidpp_device *hidpp_dev)
        if (2 + len > sizeof(response.rap.params))
                return NULL;
 
+       if (len < 4) /* logitech devices are usually at least Xddd */
+               return NULL;
+
        name = kzalloc(len + 1, GFP_KERNEL);
        if (!name)
                return NULL;