WSL2-Linux-Kernel/arch/x86/platform/intel-mid
Arnd Bergmann 0bc73048d7 x86/platform/intel-mid: Fix a format string overflow warning
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>
2017-07-20 10:46:25 +02:00
..
device_libs x86/platform/intel-mid: Fix a format string overflow warning 2017-07-20 10:46:25 +02:00
Makefile x86/platform/intel-mid: Rename mrfl.c to mrfld.c 2016-07-09 14:02:09 +02:00
intel-mid.c x86/init: Remove i8042_detect() from platform ops 2016-12-19 11:34:15 +01:00
intel_mid_vrtc.c rtc: cmos: move mc146818rtc code out of asm-generic/rtc.h 2016-06-04 00:20:00 +02:00
intel_mid_weak_decls.h x86, intel-mid: Remove "weak" from function declarations 2014-10-22 16:14:03 -06:00
mfld.c x86/platform/intel-mid: Use common power off sequence 2017-03-13 22:08:28 +01:00
mrfld.c x86/platform/intel-mid: Enable RTC on Intel Merrifield 2017-01-14 08:30:45 +01:00
pwr.c Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 15:29:06 -08:00
sfi.c x86/platform/intel-mid: Allocate RTC interrupt for Merrifield 2017-01-20 10:07:41 +01:00