From patchwork Wed Jul 16 11:21:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 33726 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C7B3A20792 for ; Wed, 16 Jul 2014 11:22:19 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id cm18sf1981285qab.3 for ; Wed, 16 Jul 2014 04:22:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=O4zHoK/fnzydBfnxUALtkHN/4pwB09AHLQjJAc/NsQ4=; b=Sw3ErKMQaAJU6mIBUdYdUrnAp15EBEX4eZ56b/1t5WFpPHOH/nMbYrLXen/xuOqY67 mf4VOGm81T58uTeLSbs5ES4A+CUSB7o+gSbUCzcCExc2xeFu3JoGtbtA/w7snr/3X8id pgoHZF/dxjAfT4SwMejrH7M1A4klZdJSzsPXx199F7vMLVCobVMvGcvbgLWIWvSlNMGQ 6+ukPt+bR/CDa/17g0CEkPmZU8gMNpvysfiI9B6NFNIN9LfNBJ7PC5WB+V829B4Ns00W mQTV+IUhx7ynjtK8jvsxB5wRvy8yXvNfShD4U1c5AWupkBgnIrZ1ixBu0fh+EniYVEno UeOg== X-Gm-Message-State: ALoCoQnR2y8Xr411V7N8YzRs0S2u4AScyXD4kemQzgk6kfH/L3Yfd2zYEUodoZLDNDOfgZEHLbym X-Received: by 10.236.126.103 with SMTP id a67mr2786399yhi.4.1405509739005; Wed, 16 Jul 2014 04:22:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.210 with SMTP id 76ls367662qgp.33.gmail; Wed, 16 Jul 2014 04:22:18 -0700 (PDT) X-Received: by 10.52.184.199 with SMTP id ew7mr5636615vdc.44.1405509738925; Wed, 16 Jul 2014 04:22:18 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ju5si8171895veb.53.2014.07.16.04.22.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Jul 2014 04:22:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id id10so1298142vcb.16 for ; Wed, 16 Jul 2014 04:22:18 -0700 (PDT) X-Received: by 10.221.34.13 with SMTP id sq13mr28490786vcb.16.1405509738826; Wed, 16 Jul 2014 04:22:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp289339vcb; Wed, 16 Jul 2014 04:22:18 -0700 (PDT) X-Received: by 10.70.103.4 with SMTP id fs4mr26013179pdb.71.1405509738032; Wed, 16 Jul 2014 04:22:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zd5si14281346pac.39.2014.07.16.04.22.17; Wed, 16 Jul 2014 04:22:17 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759202AbaGPLWH (ORCPT + 28 others); Wed, 16 Jul 2014 07:22:07 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:51098 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755445AbaGPLWF (ORCPT ); Wed, 16 Jul 2014 07:22:05 -0400 Received: by mail-pd0-f171.google.com with SMTP id z10so1082151pdj.2 for ; Wed, 16 Jul 2014 04:22:04 -0700 (PDT) X-Received: by 10.68.94.225 with SMTP id df1mr29125063pbb.86.1405509724269; Wed, 16 Jul 2014 04:22:04 -0700 (PDT) Received: from localhost.localdomain ([162.243.130.63]) by mx.google.com with ESMTPSA id vk5sm16753051pbc.44.2014.07.16.04.22.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Jul 2014 04:22:03 -0700 (PDT) From: Alex Shi To: linux@arm.linux.org.uk Cc: pawel.moll@arm.com, nico@linaro.org, sudeep.karkadanagesha@arm.com, viresh.kumar@linaro.org, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org, mark.brown@linaro.org, tixy@linaro.org Subject: [PATCH] vexpress/spc: fix a build warning on array bounds Date: Wed, 16 Jul 2014 19:21:56 +0800 Message-Id: <1405509716-19591-1-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.shi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Acked-by: Sudeep Holla Acked-by: Pawel Moll --- 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;