]> Gentwo Git Trees - linux/.git/commit
usb: Add checks for snprintf() calls in usb_alloc_dev()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 21 Mar 2025 16:49:49 +0000 (18:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Apr 2025 14:08:34 +0000 (16:08 +0200)
commit82fe5107fa3d21d6c3fba091c9dbc50495588630
treebf2d6163fe7e392ec8c5e0c9545871d1ee0b1b82
parent263d4fb2a2f1929c54aefcbb5cc32b08e5d38536
usb: Add checks for snprintf() calls in usb_alloc_dev()

When creating a device path in the driver the snprintf() takes
up to 16 characters long argument along with the additional up to
12 characters for the signed integer (as it can't see the actual limits)
and tries to pack this into 16 bytes array. GCC complains about that
when build with `make W=1`:

  drivers/usb/core/usb.c:705:25: note: ‘snprintf’ output between 3 and 28 bytes into a destination of size 16

Since everything works until now, let's just check for the potential
buffer overflow and bail out. It is most likely a never happen situation,
but at least it makes GCC happy.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250321164949.423957-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/usb.c