mirror of
https://github.com/torvalds/linux.git
synced 2025-11-07 12:10:52 +02:00
We have space for exactly three characters for the index in "max7315_%d_base",
but as GCC points out having more would cause an string overflow:
arch/x86/platform/intel-mid/device_libs/platform_max7315.c: In function 'max7315_platform_data':
arch/x86/platform/intel-mid/device_libs/platform_max7315.c:41:26: error: '%d' directive writing between 1 and 11 bytes into a region of size 9 [-Werror=format-overflow=]
sprintf(base_pin_name, "max7315_%d_base", nr);
^~~~~~~~~~~~~~~~~
arch/x86/platform/intel-mid/device_libs/platform_max7315.c:41:26: note: directive argument in the range [-2147483647, 2147483647]
arch/x86/platform/intel-mid/device_libs/platform_max7315.c:41:3: note: 'sprintf' output between 15 and 25 bytes into a destination of size 17
sprintf(base_pin_name, "max7315_%d_base", nr);
This makes it use an snprintf() to truncate the string if that happened
rather than overflowing the stack. In practice, this is safe, because
there won't be a large number of max7315 devices in the systems, and
both the format and the length are defined by the firmware interface.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170719125310.2487451-9-arnd@arndb.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
|
||
|---|---|---|
| .. | ||
| Makefile | ||
| platform_bcm43xx.c | ||
| platform_bma023.c | ||
| platform_bt.c | ||
| platform_emc1403.c | ||
| platform_gpio_keys.c | ||
| platform_lis331.c | ||
| platform_max7315.c | ||
| platform_mpu3050.c | ||
| platform_mrfld_pinctrl.c | ||
| platform_mrfld_power_btn.c | ||
| platform_mrfld_rtc.c | ||
| platform_mrfld_sd.c | ||
| platform_mrfld_spidev.c | ||
| platform_mrfld_wdt.c | ||
| platform_msic.c | ||
| platform_msic.h | ||
| platform_msic_audio.c | ||
| platform_msic_battery.c | ||
| platform_msic_gpio.c | ||
| platform_msic_ocd.c | ||
| platform_msic_power_btn.c | ||
| platform_msic_thermal.c | ||
| platform_pcal9555a.c | ||
| platform_tc35876x.c | ||
| platform_tca6416.c | ||