Files
linux/include/linux
Arnd Bergmann fd79e43632 mtd: avoid stack overflow in MTD CFI code
commit fddcca5107 upstream.

When map_word gets too large, we use a lot of kernel stack, and for
MTD_MAP_BANK_WIDTH_32, this means we use more than the recommended
1024 bytes in a number of functions:

drivers/mtd/chips/cfi_cmdset_0020.c: In function 'cfi_staa_write_buffers':
drivers/mtd/chips/cfi_cmdset_0020.c:651:1: warning: the frame size of 1336 bytes is larger than 1024 bytes [-Wframe-larger-than=]
drivers/mtd/chips/cfi_cmdset_0020.c: In function 'cfi_staa_erase_varsize':
drivers/mtd/chips/cfi_cmdset_0020.c:972:1: warning: the frame size of 1208 bytes is larger than 1024 bytes [-Wframe-larger-than=]
drivers/mtd/chips/cfi_cmdset_0001.c: In function 'do_write_buffer':
drivers/mtd/chips/cfi_cmdset_0001.c:1835:1: warning: the frame size of 1240 bytes is larger than 1024 bytes [-Wframe-larger-than=]

This can be avoided if all operations on the map word are done
indirectly and the stack gets reused between the calls. We can
mostly achieve this by selecting MTD_COMPLEX_MAPPINGS whenever
MTD_MAP_BANK_WIDTH_32 is set, but for the case that no other
bank width is enabled, we also need to use a non-constant
map_bankwidth() to convince the compiler to use less stack.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[Brian: this patch mostly achieves its goal by forcing
    MTD_COMPLEX_MAPPINGS (and the accompanying indirection) for 256-bit
    mappings; the rest of the change is mostly a wash, though it helps
    reduce stack size slightly. If we really care about supporting
    256-bit mappings though, we should consider rewriting some of this
    code to avoid keeping and assigning so many 256-bit objects on the
    stack.]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-08 07:46:01 +02:00
..
2015-10-01 12:48:11 -07:00
2015-06-25 11:49:31 +03:00
2015-10-17 21:22:08 -07:00
2015-10-07 18:08:15 +01:00
2015-08-27 20:47:09 +01:00
2016-08-20 18:09:25 +02:00
2015-05-13 12:04:55 -05:00
2015-03-25 20:28:11 -04:00
2016-03-09 15:34:52 -08:00
2015-11-07 10:40:47 -07:00
2015-02-12 18:54:15 -08:00
2015-09-08 15:35:28 -07:00
2016-07-27 09:47:33 -07:00
2015-10-18 10:14:39 -07:00
2015-01-21 19:21:30 +01:00
2014-11-10 09:27:30 -07:00
2014-12-31 13:06:50 -05:00
2015-10-30 01:47:27 -04:00
2014-10-09 11:35:48 +03:00
2015-06-24 17:49:45 -07:00
2014-10-08 16:01:41 -04:00
2014-08-06 18:01:24 -07:00
2015-05-12 10:46:53 +02:00
2015-09-08 15:35:28 -07:00
2015-03-16 21:45:54 +11:00
2015-05-05 13:40:42 -06:00
2014-06-06 16:08:13 -07:00
2016-04-20 15:42:02 +09:00
2015-10-23 05:44:28 -07:00
2014-06-02 14:56:01 -07:00
2015-08-27 19:40:58 -04:00
2015-10-01 15:06:43 +02:00
2015-10-13 19:01:25 +02:00
2015-06-25 12:06:45 +02:00
2014-03-13 12:11:00 +10:30
2016-10-28 03:01:30 -04:00
2015-08-18 15:49:15 -07:00
2015-07-28 08:50:42 +01:00
2015-04-29 17:17:17 -05:00
2015-11-23 09:44:58 +01:00
2014-05-27 17:38:11 -07:00
2015-04-14 16:49:05 -07:00
2015-10-27 18:55:31 -07:00
2015-06-24 17:49:41 -07:00
2015-10-20 22:10:45 +08:00
2015-07-21 10:39:05 -07:00
2014-03-04 13:51:06 -05:00
2014-01-27 21:02:39 -08:00
2015-06-25 04:20:04 -04:00
2016-03-03 15:07:28 -08:00
2014-01-25 03:14:05 -05:00
2015-03-11 17:56:28 -04:00
2014-11-04 13:29:38 +00:00
2015-09-10 13:29:01 -07:00
2015-09-10 13:29:01 -07:00
2015-11-06 17:50:42 -08:00
2016-12-08 07:15:24 +01:00
2014-07-09 14:58:37 +01:00
2015-04-12 21:03:31 +02:00
2015-01-25 23:17:28 -05:00
2015-10-09 17:00:32 -04:00
2015-10-06 17:08:19 +02:00
2015-10-22 08:59:18 -07:00
2015-05-26 15:23:23 +02:00
2015-06-25 01:13:43 +02:00
2014-08-08 15:57:26 -07:00
2015-02-13 21:21:41 -08:00
2016-09-30 10:18:37 +02:00
2015-04-11 15:53:35 -04:00
2014-06-12 00:21:11 -04:00
2016-10-28 03:01:30 -04:00
2014-06-04 16:53:57 -07:00
2015-06-25 17:00:39 -07:00
2016-04-12 09:08:35 -07:00
2014-06-04 16:53:56 -07:00
2015-08-17 11:25:28 -07:00
2015-10-01 09:57:59 -07:00
2015-10-19 01:01:21 +02:00
2016-06-01 12:15:52 -07:00
2015-11-23 09:44:58 +01:00
2014-11-28 16:08:16 +01:00
2015-12-04 08:38:42 -07:00
2014-04-07 16:35:53 -07:00
2015-12-13 14:30:59 -08:00
2015-03-24 09:48:14 -07:00
2015-11-13 20:34:33 -05:00
2015-09-08 15:35:28 -07:00