Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3424158ioa; Tue, 26 Apr 2022 03:29:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwczOrA00ZOCbs5ojaRq0buRIOvlUZ9AAa4LDwIDEHgzAPkZHa4gpU2KHVbxCgVLmI2x7cI X-Received: by 2002:a50:baa8:0:b0:415:b0bc:6353 with SMTP id x37-20020a50baa8000000b00415b0bc6353mr24017082ede.220.1650968969343; Tue, 26 Apr 2022 03:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650968969; cv=none; d=google.com; s=arc-20160816; b=P5ioXXdt950Vzq0ntfvjzUSRONceUULC16uwbSvc3L+oVSiB3eAOYbK7z4v472YGVx E2/dJVzeIBuDvTwOlHU0lCB7QQtGz2BMuY5OI/kPH4rmqZBZJzOE0kF1WTxAJ0HANcpE pAKjkwtXrJkbviPmD7Jf8t0R5ryfzKwi/mZiaDF89S13V/VtQjgZlin1obmCV1owJdvD G82v6Gimn1ztx2zYlCdFnZEojJ8uCqqw+/7rCVeK9s84sDx4X2ocnnPYJdUtstosDM6P Q22DpGlLaOj1wRj1N5dCHrZnawMLXINGNJ6nfTaLMYOyftsS3mijV8n7b00iq6OWvYzc mAyQ== 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=ByTh2fER+tS+v8E0odebezenLn3NPSrHHmLHLDX+U/S6HZ8QQG3yC0mA28997lBXtP VjE5qz5TRgz//nE4KIRRwQbV/BUgBOjjsh/nw+vJNjYTL1YsgRl1A48G7FTspJ0GDXLy yOvu2ZaJR4gKtKIqObFBgOIZIa9+vkoSzNxh5W2WnPk2p/MhKuY0islDh6r5hrt3O45G TBpM92jFjH4KF96j3BjjQEF9zmBGz/t6OpunNyi/laCGnEcYhOXzzTTBZ2y8PiOMR6rP sY/Wjq24yCOpCYPKBWIQoUJ7X5LWsQsvoYglPuDbPTYUc9EEvPHcQuSN3AyRy0kBnt4i rSsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NmzFfO9m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw19-20020a170907a0d300b006df76385d83si13498912ejc.547.2022.04.26.03.29.05; Tue, 26 Apr 2022 03:29:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NmzFfO9m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347024AbiDZJJm (ORCPT + 99 others); Tue, 26 Apr 2022 05:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346615AbiDZIuN (ORCPT ); Tue, 26 Apr 2022 04:50:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBEC5155294; Tue, 26 Apr 2022 01:38:28 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2AD0BB81D0B; Tue, 26 Apr 2022 08:38:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6905EC385A4; Tue, 26 Apr 2022 08:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962305; bh=y4FzcMqIYjP6yJMMswEni40ksnSonHHl5KEbQHYCCgw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NmzFfO9mbqis2ybtAWfm+sPAeBcstgq0d4e14gtd+Myxd69Wes5emxq3/8F9S58YD EvE0DnBJ6rbixOMqYDZtAijh1ItXp8llvd1vd3MUD8WOi5p8J2oNMi3Lr4hUfde98t tc/nqLDshpkp53V47Cu0FdqHvOs0X717W9y5WMkk= 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.15 053/124] ARM: vexpress/spc: Avoid negative array index when !SMP Date: Tue, 26 Apr 2022 10:20:54 +0200 Message-Id: <20220426081748.809250586@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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