Commit 98a0465
printk: fix illegal pbufs access for !CONFIG_PRINTK
When CONFIG_PRINTK is not set, PRINTK_MESSAGE_MAX is 0. This
leads to a zero-sized array @outbuf in @printk_shared_pbufs. In
console_flush_all() a pointer to the first element of the array
is assigned with:
char *outbuf = &printk_shared_pbufs.outbuf[0];
For !CONFIG_PRINTK this leads to a compiler warning:
warning: array subscript 0 is outside array bounds of
'char[0]' [-Warray-bounds]
This is not really dangerous because printk_get_next_message()
always returns false for !CONFIG_PRINTK, which leads to @outbuf
never being used. However, it makes no sense to even compile
these functions for !CONFIG_PRINTK.
Extend the existing '#ifdef CONFIG_PRINTK' block to contain
the formatting and emitting functions since these have no
purpose in !CONFIG_PRINTK. This also allows removing several
more !CONFIG_PRINTK dummies as well as moving
@suppress_panic_printk into a CONFIG_PRINTK block.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202309201724.M9BMAQIh-lkp@intel.com/
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20230920155238.670439-1-john.ogness@linutronix.de1 parent 9757acd commit 98a0465
1 file changed
Lines changed: 18 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 105 | | |
112 | 106 | | |
113 | 107 | | |
| |||
445 | 439 | | |
446 | 440 | | |
447 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| |||
2346 | 2346 | | |
2347 | 2347 | | |
2348 | 2348 | | |
2349 | | - | |
2350 | | - | |
2351 | | - | |
2352 | | - | |
2353 | | - | |
2354 | | - | |
2355 | | - | |
2356 | | - | |
2357 | | - | |
2358 | | - | |
2359 | | - | |
2360 | | - | |
2361 | | - | |
2362 | | - | |
2363 | | - | |
2364 | | - | |
2365 | 2349 | | |
2366 | 2350 | | |
2367 | 2351 | | |
| |||
2715 | 2699 | | |
2716 | 2700 | | |
2717 | 2701 | | |
| 2702 | + | |
| 2703 | + | |
2718 | 2704 | | |
2719 | 2705 | | |
2720 | 2706 | | |
| |||
2729 | 2715 | | |
2730 | 2716 | | |
2731 | 2717 | | |
2732 | | - | |
2733 | 2718 | | |
2734 | 2719 | | |
2735 | 2720 | | |
| |||
2761 | 2746 | | |
2762 | 2747 | | |
2763 | 2748 | | |
2764 | | - | |
2765 | | - | |
2766 | | - | |
2767 | 2749 | | |
2768 | 2750 | | |
2769 | 2751 | | |
| |||
2921 | 2903 | | |
2922 | 2904 | | |
2923 | 2905 | | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
2924 | 2916 | | |
2925 | 2917 | | |
2926 | 2918 | | |
| |||
0 commit comments