Skip to content

Commit 6b436d2

Browse files
keesgregkh
authored andcommitted
sh: machvec: Use char[] for section boundaries
[ Upstream commit c5783af ] As done for other sections, define the extern as a character array, which relaxes many of the compiler-time object size checks, which would otherwise assume it's a single long. Solves the following build error: arch/sh/kernel/machvec.c: error: array subscript 'struct sh_machine_vector[0]' is partly outside array bounds of 'long int[1]' [-Werror=array-bounds]: => 105:33 Cc: Yoshinori Sato <[email protected]> Cc: Rich Felker <[email protected]> Cc: [email protected] Reported-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Fixes: 9655ad0 ("sh: Fixup machvec support.") Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Acked-by: Rich Felker <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent ab3fda4 commit 6b436d2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

arch/sh/include/asm/sections.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <asm-generic/sections.h>
55

6-
extern long __machvec_start, __machvec_end;
6+
extern char __machvec_start[], __machvec_end[];
77
extern char __uncached_start, __uncached_end;
88
extern char __start_eh_frame[], __stop_eh_frame[];
99

arch/sh/kernel/machvec.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#define MV_NAME_SIZE 32
2323

2424
#define for_each_mv(mv) \
25-
for ((mv) = (struct sh_machine_vector *)&__machvec_start; \
26-
(mv) && (unsigned long)(mv) < (unsigned long)&__machvec_end; \
25+
for ((mv) = (struct sh_machine_vector *)__machvec_start; \
26+
(mv) && (unsigned long)(mv) < (unsigned long)__machvec_end; \
2727
(mv)++)
2828

2929
static struct sh_machine_vector * __init get_mv_byname(const char *name)
@@ -89,8 +89,8 @@ void __init sh_mv_setup(void)
8989
if (!machvec_selected) {
9090
unsigned long machvec_size;
9191

92-
machvec_size = ((unsigned long)&__machvec_end -
93-
(unsigned long)&__machvec_start);
92+
machvec_size = ((unsigned long)__machvec_end -
93+
(unsigned long)__machvec_start);
9494

9595
/*
9696
* Sanity check for machvec section alignment. Ensure
@@ -104,7 +104,7 @@ void __init sh_mv_setup(void)
104104
* vector (usually the only one) from .machvec.init.
105105
*/
106106
if (machvec_size >= sizeof(struct sh_machine_vector))
107-
sh_mv = *(struct sh_machine_vector *)&__machvec_start;
107+
sh_mv = *(struct sh_machine_vector *)__machvec_start;
108108
}
109109

110110
printk(KERN_NOTICE "Booting machvec: %s\n", get_system_type());

0 commit comments

Comments
 (0)