Skip to content

Commit e160cc1

Browse files
Alex Shiolofj
authored andcommitted
vexpress/spc: fix a build warning on array bounds
With ARCH_VEXPRESS_SPC option, kernel build has the following warning: arch/arm/mach-vexpress/spc.c: In function ‘ve_spc_clk_init’: arch/arm/mach-vexpress/spc.c:431:38: warning: array subscript is below array bounds [-Warray-bounds] struct ve_spc_opp *opps = info->opps[cluster]; ^ since 'cluster' maybe '-1' in UP system. This patch does a active checking to fix this issue. Signed-off-by: Alex Shi <alex.shi@linaro.org> Acked-by: Pawel Moll <pawel.moll@arm.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Olof Johansson <olof@lixom.net>
1 parent 98fd150 commit e160cc1

File tree

1 file changed

+11
-3
lines changed
  • arch/arm/mach-vexpress

1 file changed

+11
-3
lines changed

arch/arm/mach-vexpress/spc.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,15 @@ static int ve_spc_populate_opps(uint32_t cluster)
426426

427427
static int ve_init_opp_table(struct device *cpu_dev)
428428
{
429-
int cluster = topology_physical_package_id(cpu_dev->id);
430-
int idx, ret = 0, max_opp = info->num_opps[cluster];
431-
struct ve_spc_opp *opps = info->opps[cluster];
429+
int cluster;
430+
int idx, ret = 0, max_opp;
431+
struct ve_spc_opp *opps;
432+
433+
cluster = topology_physical_package_id(cpu_dev->id);
434+
cluster = cluster < 0 ? 0 : cluster;
435+
436+
max_opp = info->num_opps[cluster];
437+
opps = info->opps[cluster];
432438

433439
for (idx = 0; idx < max_opp; idx++, opps++) {
434440
ret = dev_pm_opp_add(cpu_dev, opps->freq * 1000, opps->u_volt);
@@ -537,6 +543,8 @@ static struct clk *ve_spc_clk_register(struct device *cpu_dev)
537543
spc->hw.init = &init;
538544
spc->cluster = topology_physical_package_id(cpu_dev->id);
539545

546+
spc->cluster = spc->cluster < 0 ? 0 : spc->cluster;
547+
540548
init.name = dev_name(cpu_dev);
541549
init.ops = &clk_spc_ops;
542550
init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE;

0 commit comments

Comments
 (0)