Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4460659ioa; Wed, 27 Apr 2022 04:30:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB6KuTN+XhLu6IcHmjgs/vntWgD0fuDZ0nj08SxI0/2Nss1JMscpTrj7tipujovnUXqtAw X-Received: by 2002:a05:6a00:b4d:b0:50d:7e9f:1ff0 with SMTP id p13-20020a056a000b4d00b0050d7e9f1ff0mr3481667pfo.80.1651059011773; Wed, 27 Apr 2022 04:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651059011; cv=none; d=google.com; s=arc-20160816; b=uoZ4eJ9p/152t9kn3D4K3dwob5RcAfHg4SjfFZPmqkWLVOUIGn/B5heufuEUDmXXqk P7x2jpfIFoVRpVEGdNYP2ETpFTWi+CFONH+pXumiXQx9SzyoS57b7WlAWgRL+97MHync D/9tsSj0qhbT34t+nNp86e5MSt4e/k6mdTVrvqq2WSC0xwT+xk/ibwQkz8qkp+0pyVNX 7wSdj/lNfMtJetunuIicGBvQendjp+cGlWkJoFl5XWW7wbIV3AcEUre61EFvv4apEP1T m14oUYE+xmVmOHj/Z48pyeD4l82j8246bYcYdE52sWLz3INc2uOFlhpV9pII6eVrbqLV OGWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gNoiKTbXRqekK9GM2rZUSWst6rVLQIWc7+0J9ITYqeE=; b=HwERnWP2yJbMfZ9XPpptFtoqlK2HSkSzZzBjWW32/wFC54T+RKZqB2bIMktNAQp4YB Vw3UmeAilRjvIWdlEZVfEINAL4t7A/WQM74akMTJ2Grck8wy1F7ZJPd1HQOB6vKcU3I8 jl9UiPD7DZAkp/0nxkVvCOlSiXYLgoivov1spUpo74dGWw+KHX+suHgGcQcDtOBskSRH ZCzS5854nR6qExvyTv98M7cuS/OS+TU6MtT1x1gThJBCADidjoE3HepNA6X9cl1c0BjR MYtisL0tgBu09fw+3p9nKQe7HrVztT1fC38QCpTF1/Uz2cm4DwYwd2WMZqlDMMn3L+IK bnKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e1osvW2D; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f9-20020a170902ce8900b0015cfd262931si1420330plg.104.2022.04.27.04.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:30:11 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e1osvW2D; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7AD3534849D; Wed, 27 Apr 2022 03:17:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348369AbiDZJfG (ORCPT + 99 others); Tue, 26 Apr 2022 05:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347897AbiDZJGV (ORCPT ); Tue, 26 Apr 2022 05:06:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F38EAC073; Tue, 26 Apr 2022 01:46:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BDC42604F5; Tue, 26 Apr 2022 08:46:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B04C2C385A4; Tue, 26 Apr 2022 08:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962812; bh=y4FzcMqIYjP6yJMMswEni40ksnSonHHl5KEbQHYCCgw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e1osvW2DjRtrupRpOuzwDpRUIqLs7RGXzp3zpV5WE4ERzgMycDPjw3oqY4ce8T0zK UPHA5XDPSY0pLZ54H1lwAJ5FDa0Zylfw5LwvYorRG+axwim90l7AC/k8OYCYOLz+3q N1ZoT6wFx843zWV8CxiX06XK+kGAe7hh7NMPycI0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liviu Dudau , Sudeep Holla , Lorenzo Pieralisi , Russell King , linux-arm-kernel@lists.infradead.org, Kees Cook , Sasha Levin Subject: [PATCH 5.17 060/146] ARM: vexpress/spc: Avoid negative array index when !SMP Date: Tue, 26 Apr 2022 10:20:55 +0200 Message-Id: <20220426081751.754307470@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081750.051179617@linuxfoundation.org> References: <20220426081750.051179617@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook [ Upstream commit b3f1dd52c991d79118f35e6d1bf4d7cb09882e38 ] 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 Cc: Sudeep Holla Cc: Lorenzo Pieralisi Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Acked-by: Liviu Dudau Signed-off-by: Kees Cook Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- arch/arm/mach-vexpress/spc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c index 1da11bdb1dfb..1c6500c4e6a1 100644 --- a/arch/arm/mach-vexpress/spc.c +++ b/arch/arm/mach-vexpress/spc.c @@ -580,7 +580,7 @@ static int __init ve_spc_clk_init(void) } cluster = topology_physical_package_id(cpu_dev->id); - if (init_opp_table[cluster]) + if (cluster < 0 || init_opp_table[cluster]) continue; if (ve_init_opp_table(cpu_dev)) -- 2.35.1