]> www.infradead.org Git - users/jedix/linux-maple.git/commit
usb: core: Use sysfs_emit_at() when showing dynamic IDs
authorHanne-Lotta Mäenpää <hannelotta@gmail.com>
Sat, 21 Jun 2025 16:40:05 +0000 (19:40 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jun 2025 14:40:12 +0000 (15:40 +0100)
commit711d41ab4a0e4230e394fd5da5b85604ddb9fc51
tree4c9d45b0abd0586177af9607704d51751de0f907
parent8b4f6fafed6cd9a36716dd4846f27cc543f52303
usb: core: Use sysfs_emit_at() when showing dynamic IDs

When formatting the dynamic USB device IDs to show to
the user space, instead of scnprintf() function use
sysfs_emit_at(). The functions are equivalent, but
using the latter is recommended as it ensures that
no buffer overruns occur.

Testing the change can be done by assigning new IDs
to the USB driver's sysfs attribute new_id,
and then checking that the same values are returned.

For example:

echo 4533 7515 > /sys/bus/usb/drivers/usbfs/new_id
cat /sys/bus/usb/drivers/usbfs/new_id

The output should match the assigned IDs (4533 7515).

Signed-off-by: Hanne-Lotta Mäenpää <hannelotta@gmail.com>
Link: https://lore.kernel.org/r/20250621164005.4004-1-hannelotta@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/driver.c