From: Sudeep Holla <sudeep.holla@arm.com>
To: Alex Shi <alex.shi@linaro.org>,
"linux@arm.linux.org.uk" <linux@arm.linux.org.uk>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
Pawel Moll <Pawel.Moll@arm.com>,
"nico@linaro.org" <nico@linaro.org>,
"viresh.kumar@linaro.org" <viresh.kumar@linaro.org>,
"rafael.j.wysocki@intel.com" <rafael.j.wysocki@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mark.brown@linaro.org" <mark.brown@linaro.org>,
"tixy@linaro.org" <tixy@linaro.org>
Subject: Re: [PATCH] vexpress/spc: fix a build warning on array bounds
Date: Wed, 16 Jul 2014 12:28:11 +0100 [thread overview]
Message-ID: <53C661CB.7040306@arm.com> (raw)
In-Reply-To: <1405509716-19591-1-git-send-email-alex.shi@linaro.org>
Hi Alex,
On 16/07/14 12:21, Alex Shi wrote:
> 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.
>
Good catch, looks fine to me.
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Alex Shi <alex.shi@linaro.org>
> ---
> arch/arm/mach-vexpress/spc.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
> index c26ef5b..4833544 100644
> --- a/arch/arm/mach-vexpress/spc.c
> +++ b/arch/arm/mach-vexpress/spc.c
> @@ -426,9 +426,15 @@ static int ve_spc_populate_opps(uint32_t cluster)
>
> static int ve_init_opp_table(struct device *cpu_dev)
> {
> - int cluster = topology_physical_package_id(cpu_dev->id);
> - int idx, ret = 0, max_opp = info->num_opps[cluster];
> - struct ve_spc_opp *opps = info->opps[cluster];
> + int cluster;
> + int idx, ret = 0, max_opp;
> + struct ve_spc_opp *opps;
> +
> + cluster = topology_physical_package_id(cpu_dev->id);
> + cluster = cluster < 0 ? 0 : cluster;
> +
> + max_opp = info->num_opps[cluster];
> + opps = info->opps[cluster];
>
> for (idx = 0; idx < max_opp; idx++, opps++) {
> 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)
> spc->hw.init = &init;
> spc->cluster = topology_physical_package_id(cpu_dev->id);
>
> + spc->cluster = spc->cluster < 0 ? 0 : spc->cluster;
> +
> init.name = dev_name(cpu_dev);
> init.ops = &clk_spc_ops;
> init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE;
>
next prev parent reply other threads:[~2014-07-16 11:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-16 11:21 [PATCH] vexpress/spc: fix a build warning on array bounds Alex Shi
2014-07-16 11:28 ` Sudeep Holla [this message]
2014-08-29 1:45 ` Alex Shi
2014-08-29 4:00 ` Pawel Moll
2014-08-31 17:23 ` Olof Johansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53C661CB.7040306@arm.com \
--to=sudeep.holla@arm.com \
--cc=Pawel.Moll@arm.com \
--cc=alex.shi@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.brown@linaro.org \
--cc=nico@linaro.org \
--cc=rafael.j.wysocki@intel.com \
--cc=tixy@linaro.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.