Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HID: usbhid: Insert USB bus/device ID into HID name #6356

Draft
wants to merge 1 commit into
base: rpi-6.6.y
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions drivers/hid/usbhid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,17 +1388,21 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
else if (intf->cur_altsetting->desc.bInterfaceProtocol == 0)
hid->type = HID_TYPE_USBNONE;

if (dev->manufacturer)
strscpy(hid->name, dev->manufacturer, sizeof(hid->name));
snprintf(hid->name, sizeof(hid->name), "usb-%s ", dev_name(&dev->dev));

if (dev->manufacturer) {
strlcat(hid->name, dev->manufacturer, sizeof(hid->name));
}

if (dev->product) {
if (dev->manufacturer)
strlcat(hid->name, " ", sizeof(hid->name));
strlcat(hid->name, dev->product, sizeof(hid->name));
}

if (!strlen(hid->name))
snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x",
if (strlen(hid->name) == strlen(dev_name(&dev->dev)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the snprintf above, and the fact that other changes just append, how can this condition ever be true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't.
Too many revisions switching from strscpy to snprintf (to add the usb- prefix), and missing updating this condition.

Ideally this issue wants to be sorted further up the stack (xinput was always happy with multiple identical devices, although you had to reference them by id number rather than name), so I'll have a word with Simon and David T later on.

snprintf(hid->name, sizeof(hid->name), "usb-%s HID %04x:%04x",
dev_name(&dev->dev),
le16_to_cpu(dev->descriptor.idVendor),
le16_to_cpu(dev->descriptor.idProduct));

Expand Down