• Kees Cook's avatar
    ARM: vexpress/spc: Avoid negative array index when !SMP · b3f1dd52
    Kees Cook authored
    When building multi_v7_defconfig+CONFIG_SMP=n, -Warray-bounds exposes
    a couple negative array index accesses:
    
    arch/arm/mach-vexpress/spc.c: In function 've_spc_clk_init':
    arch/arm/mach-vexpress/spc.c:583:21: warning: array subscript -1 is below array bounds of 'bool[2]' {aka '_Bool[2]'} [-Warray-bounds]
      583 |   if (init_opp_table[cluster])
          |       ~~~~~~~~~~~~~~^~~~~~~~~
    arch/arm/mach-vexpress/spc.c:556:7: note: while referencing 'init_opp_table'
      556 |  bool init_opp_table[MAX_CLUSTERS] = { false };
          |       ^~~~~~~~~~~~~~
    arch/arm/mach-vexpress/spc.c:592:18: warning: array subscript -1 is below array bounds of 'bool[2]' {aka '_Bool[2]'} [-Warray-bounds]
      592 |    init_opp_table[cluster] = true;
          |    ~~~~~~~~~~~~~~^~~~~~~~~
    arch/arm/mach-vexpress/spc.c:556:7: note: while referencing 'init_opp_table'
      556 |  bool init_opp_table[MAX_CLUSTERS] = { false };
          |       ^~~~~~~~~~~~~~
    
    Skip this logic when built !SMP.
    
    Link: https://lore.kernel.org/r/20220331190443.851661-1-keescook@chromium.org
    
    
    Cc: Liviu Dudau <liviu.dudau@arm.com>
    Cc: Sudeep Holla <sudeep.holla@arm.com>
    Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Cc: Russell King <linux@armlinux.org.uk>
    Cc: linux-arm-kernel@lists.infradead.org
    Acked-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
    b3f1dd52
spc.c 14.2 KB