sparc: fix array bounds error setting up PCIC NMI trap
PATCH 1/1 sparc: fix array bounds error setting up PCIC NMI trap
From a sparc64 defconfig:
CC arch/sparc/kernel/pcic.oarch/sparc/kernel/pcic.c: In function 'pcic_probe':arch/sparc/kernel/pcic.c:359:33: error: array subscript is above array bounds [-Werror=array-bounds] arch/sparc/kernel/pcic.c:359:8: error: array subscript is above array bounds [-Werror=array-bounds] arch/sparc/kernel/pcic.c:360:33: error: array subscript is above array bounds [-Werror=array-bounds] arch/sparc/kernel/pcic.c:360:8: error: array subscript is above array bounds [-Werror=array-bounds] arch/sparc/kernel/pcic.c:361:33: error: array subscript is above array bounds [-Werror=array-bounds] arch/sparc/kernel/pcic.c:361:8: error: array subscript is above array bounds [-Werror=array-bounds]
cc1: all warnings being treated as errors
I'm not particularly familiar with sparc but t_nmi (defined in head_32.S via the TRAP_ENTRY macro) and pcic_nmi_trap_patch (defined in entry.S) both appear to be 4 instructions long and I presume from the usage that instructions are int sized.
--- arch/sparc/kernel/pcic.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/sparc/kernel/pcic.c +2 -2
@@ -352,8 +352,8 @@ int __init pcic_probe(void)strcpy (pbm->prom_name, namebuf); { -extern volatile int t_nmi[1 ]; -extern int pcic_nmi_trap_patch[1 ]; +extern volatile int t_nmi[4 ]; +extern int pcic_nmi_trap_patch[4 ]; t_nmi[0 ] = pcic_nmi_trap_patch[0 ]; t_nmi[1 ] = pcic_nmi_trap_patch[1 ];
Signature · 1 line
1.7.2.5
David Miller
maintainerFrom: Ian Campbell <[email protected]>
Date: Thu, 18 Aug 2011 09:14:57 +0100
Quoted 2 lines
Quoted 1 line
From a sparc64 defconfig:
CC
arch/sparc/kernel/pcic.o
A sparc64 defconfig? This is code only built for 32-bit sparc :-)
Quoted 7 lines · David Miller
From: Ian Campbell <[email protected]>
Date: Thu, 18 Aug 2011 09:14:57 +0100Quoted 2 lines
Quoted 1 line
From a sparc64 defconfig:
CC
arch/sparc/kernel/pcic.oA sparc64 defconfig? This is code only built for 32-bit sparc :-)
My local script confused me, it translated sparc64 into ARCH=sparc for me, where it turns out the defconfig = sparc32_defconfig, so I was actually building 32 bit. Sorry about that.
Turns out I also saw this on 32-bit sparc defconfig, which is hardly surprising given the two .configs are exactly the same ;-)
Ian.
Quoted 7 lines · Ian Campbell
Quoted 6 lines · David Miller
From: Ian Campbell <[email protected]>
Date: Thu, 18 Aug 2011 09:14:57 +0100Quoted 2 lines
Quoted 1 line
From a sparc64 defconfig:
CC
arch/sparc/kernel/pcic.o
Quoted 8 lines
Quoted 1 line
A sparc64 defconfig? This is code only built for 32-bit sparc :-)
My local script confused me, it translated sparc64 into ARCH=sparc for me, where it turns out the defconfig =
sparc32_defconfig, so I was actually building 32 bit. Sorry about that.Turns out I also saw this on 32-bit sparc defconfig, which is hardly surprising given the two .configs are exactly the same ;-)
sparse complains too - I just never got around to fix it up.
If you do nto beat me I will look at it soon.
Sam
Quoted 14 lines · Sam Ravnborg
Quoted 13 lines · Ian Campbell
Quoted 7 lines · David Miller
From: Ian Campbell <[email protected]>
Date: Thu, 18 Aug 2011 09:14:57 +0100Quoted 2 lines
Quoted 1 line
From a sparc64 defconfig:
CC
arch/sparc/kernel/pcic.oA sparc64 defconfig? This is code only built for 32-bit sparc :-)
My local script confused me, it translated sparc64 into ARCH=sparc for me, where it turns out the defconfig =
sparc32_defconfig, so I was actually building 32 bit. Sorry about that.
Quoted 5 lines
Quoted 2 lines
Turns out I also saw this on 32-bit sparc defconfig, which is hardly surprising given the two .configs are exactly the same ;-)
sparse complains too - I just never got around to fix it up.
If you do nto beat me I will look at it soon.
With my patch applied I don't see any sparse warnings for these lines ofpcic.c, although there are others:
CHECK /local/scratch/ianc/devel/kernels/linux-2.6/arch/sparc/kernel/pcic.carch/sparc/kernel/pcic.c:163:14: warning: symbol 'pcic_regs' was not declared. Should it be static? arch/sparc/kernel/pcic.c:164:14: warning: symbol 'pcic_speculative' was not declared. Should it be static? arch/sparc/kernel/pcic.c:165:14: warning: symbol 'pcic_trapped' was not declared. Should it be static? arch/sparc/kernel/pcic.c:331:66: warning: Using plain integer as NULL pointer arch/sparc/kernel/pcic.c:343:66: warning: Using plain integer as NULL pointer arch/sparc/kernel/pcic.c:539:38: warning: Using plain integer as NULL pointer arch/sparc/kernel/pcic.c:677:1: warning: symbol 'pcic_pin_to_irq' was not declared. Should it be static? arch/sparc/kernel/pcic.c:718:5: warning: symbol 'pci_gettimeoffset' was not declared. Should it be static? arch/sparc/kernel/pcic.c:787:6: warning: symbol 'pcic_nmi' was not declared. Should it be static? arch/sparc/kernel/pcic.c:883:5: warning: symbol 'pcibios_assign_resource' was not declared. Should it be static?
CC arch/sparc/kernel/pcic.o
Ian.
Hi Ian.
Quoted 15 lines · Ian Campbell
Quoted 14 lines · Sam Ravnborg
Quoted 13 lines · Ian Campbell
Quoted 7 lines · David Miller
From: Ian Campbell <[email protected]>
Date: Thu, 18 Aug 2011 09:14:57 +0100Quoted 2 lines
Quoted 1 line
From a sparc64 defconfig:
CC
arch/sparc/kernel/pcic.oA sparc64 defconfig? This is code only built for 32-bit sparc :-)
My local script confused me, it translated sparc64 into ARCH=sparc for me, where it turns out the defconfig =
sparc32_defconfig, so I was actually building 32 bit. Sorry about that.
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Turns out I also saw this on 32-bit sparc defconfig, which is hardly surprising given the two .configs are exactly the same ;-)
sparse complains too - I just never got around to fix it up.
If you do nto beat me I will look at it soon.
Somehow I missed that you already had provided a patch in the first mail. this patch has my:
Quoted 15 lines
With my patch applied I don't see any sparse warnings for these lines of
pcic.c, although there are others:
CHECK /local/scratch/ianc/devel/kernels/linux-2.6/arch/sparc/kernel/pcic.carch/sparc/kernel/pcic.c:163:14: warning: symbol 'pcic_regs' was not declared. Should it be static?arch/sparc/kernel/pcic.c:164:14: warning: symbol 'pcic_speculative' was not declared. Should it be static?arch/sparc/kernel/pcic.c:165:14: warning: symbol 'pcic_trapped' was not declared. Should it be static?arch/sparc/kernel/pcic.c:331:66: warning: Using plain integer as NULL pointerarch/sparc/kernel/pcic.c:343:66: warning: Using plain integer as NULL pointerarch/sparc/kernel/pcic.c:539:38: warning: Using plain integer as NULL pointerarch/sparc/kernel/pcic.c:677:1: warning: symbol 'pcic_pin_to_irq' was not declared. Should it be static?arch/sparc/kernel/pcic.c:718:5: warning: symbol 'pci_gettimeoffset' was not declared. Should it be static?arch/sparc/kernel/pcic.c:787:6: warning: symbol 'pcic_nmi' was not declared. Should it be static?arch/sparc/kernel/pcic.c:883:5: warning: symbol 'pcibios_assign_resource' was not declared. Should it be static?
CCarch/sparc/kernel/pcic.oA
Trivial stuff - mostly missing extern stuff.
But we should kill these warnings soon so they do not hide more serious warnings.
Sam
From: Sam Ravnborg <[email protected]>
Date: Thu, 18 Aug 2011 21:06:26 +0200
Quoted 20 lines
Hi Ian.
Quoted 17 lines · Ian Campbell
Quoted 16 lines · Sam Ravnborg
Quoted 15 lines · Ian Campbell
Quoted 7 lines · David Miller
From: Ian Campbell <[email protected]>
Date: Thu, 18 Aug 2011 09:14:57 +0100Quoted 2 lines
Quoted 1 line
From a sparc64 defconfig:
CC
arch/sparc/kernel/pcic.oA sparc64 defconfig? This is code only built for 32-bit sparc :-)
My local script confused me, it translated sparc64 into ARCH=sparc for me, where it turns out the defconfig =
sparc32_defconfig, so I was actually building 32 bit. Sorry about that.Turns out I also saw this on 32-bit sparc defconfig, which is hardly surprising given the two .configs are exactly the same ;-)
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
sparse complains too - I just never got around to fix it up.
If you do nto beat me I will look at it soon.
Somehow I missed that you already had provided a patch in the first mail. this patch has my:
Reviewed-by Sam Ravnborg <[email protected]>
Applied, thanks everyone.