]> www.infradead.org Git - users/jedix/linux-maple.git/commit
leds: core: Bail out when composed name can't fit the buffer
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 18 Mar 2025 16:04:29 +0000 (18:04 +0200)
committerLee Jones <lee@kernel.org>
Tue, 15 Apr 2025 16:57:55 +0000 (17:57 +0100)
commitee44a1def7ee4c6f9f04a02bfa1a106ee41434d3
tree67e12444691872025a7224214919da8d295fb0c0
parent06d99fcf1f87d5b6bf1c7dd0f7ec422304a47f31
leds: core: Bail out when composed name can't fit the buffer

GCC compiler complains about snprintf() calls that may potentially cut
the output:

 drivers/leds/led-core.c:551:78: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
 drivers/leds/led-core.c:554:78: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
 ...

Fix these by checking for the potential overflow. This requires
to align all the branches to use the same callee, i.e. snprintf(),
otherwise the code will be blown up and return different error codes
for the different branches.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20250318160524.2979982-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/led-core.c