From patchwork Tue Jul 19 17:59:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 591662 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp4210254max; Tue, 19 Jul 2022 11:05:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1txlKNY4G0Nf0QntxlnveL6KU68HBa/BYhvSEV/7j3Bf4utIUOiEtm5PCo4b9pe7vQCYOIV X-Received: by 2002:a05:620a:3726:b0:6b2:70db:22fe with SMTP id de38-20020a05620a372600b006b270db22femr22344235qkb.564.1658253910321; Tue, 19 Jul 2022 11:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658253910; cv=none; d=google.com; s=arc-20160816; b=t2hSfEx+a1EDaMQ7ahVX0Hvg2MlLFDf47YAuh8LdBRLUUdxlWiFzCKqBVOLghQCawC OBEWOFKkFgCKfNWHC5RKkimIunvIDia6NMWyDeIKP0U9SpewWbo9rCScsNhn+FOwlZyx GnIREkmNxFNYWEDN47xu2gY8u6FpV65Tv7DbSBA7Tk1ZOTld7vG4ZYsBasVuc/YW1Mdj rK+fmv8eRQHFw9mmXTOsuZ7A2X3DCXs13LzHIALmnotj4plTBYPFyAOwy297ws972UwT PTVv8TZqcYGtfrz+KBhXeV8MPaSozbRsXTFSkTa5uiy1y/htKmBiCLJb8X5HImNhaLJY i82A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7kucxed5pd2yWAJLsvl/juNcXUDwpeqo29sK0pxQgQk=; b=fp45hefzzUlyTd4fKThbwst7gw67GvJM8TVgucStPpSm1Q40fUHl0f0svWEcAE4Bpi kRq1eVjhsrhOwfhY2ZRdfGE2pBP6xxmqNU+RFE/YSRSRiq770NHFPNPEIicC/ssez2FI t9dpaQWl/K4YfIuSmuK4//mLYQXMQYA2b2XCXBcyu6fHh1qC/B0fChSmhr3YV3x84dIJ J7vB9cdtMYeFcktpCa9zdYTkPrQdYpq/dJg9qkCE9+W4q0bYCisfkNmEBOfMRYkq9qxH kftfYzS8iIIO1X8KhJhv5zNTYktFGgOHqJOGSPOCk7TW3EpczDOKmiXzVEPCOQcCsQy3 HTPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rQ4vdTcn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k4-20020ad45be4000000b0047093029f5csi6967087qvc.466.2022.07.19.11.05.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Jul 2022 11:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rQ4vdTcn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDran-0002t0-Sn for patch@linaro.org; Tue, 19 Jul 2022 14:05:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDrWO-0006IW-BA for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:00:36 -0400 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]:37657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDrWM-0006BV-M1 for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:00:36 -0400 Received: by mail-ot1-x334.google.com with SMTP id l9-20020a056830268900b006054381dd35so12303071otu.4 for ; Tue, 19 Jul 2022 11:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7kucxed5pd2yWAJLsvl/juNcXUDwpeqo29sK0pxQgQk=; b=rQ4vdTcnXPQo8ZPORv47uUEPEeOGEnnFyR2mVSsvIj9WuOyP4PHiQFh/P9Kwq/NvAX KjlJuAjLmmPaxDIWG1YJtm9TW+LydZfIELmJ1VhUc2UFlOWOZnWePX7T4GFEkUKAA7Pb 4BmYn+uXcRnTySRn+V2LmR3ukXvSOnY6sGGeYtYVg0lzs21u0t2qobKYouBu6yXZSDdY VRSW3viENXP/TSFdEF9nYxmVVetrD5zICwMc+NA+dX1mVskFaHAjDiDA6173ivMO5dC3 JfidYvj7YK6AuHDjZ7gFwyKe0Xmb2XqtMCjb47K/cGKhEREbbprRUWCSSt8Zee3n4zFd z8wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7kucxed5pd2yWAJLsvl/juNcXUDwpeqo29sK0pxQgQk=; b=U+VnPeMGegFKqwV8Diq74BG+ydMAcH2hcayeP2wBtesEgQUV8kjz+QF1E7+ilu6dy3 eZR7Hp7/r4uuvkHKrv0VyDmFvYUOFmdZ5s5t6twVKuJZN3eVZD8m+UU4VvpulS3cieQc wPz6W1kroadE16yeTGEGU7LRZcr+smbtGmUmmFvzjGuqJN4F7vK6Gr+3ONmT0JkWKixs ua5CJDM1Iry0bOXq/kfE80dUXNd46JKSG5adWh+1xqbE3BYWnsmEwGUiP+o3b16N3oI+ Tyha4KmyeZu3oAyq1TRA27olkoXDoqCdNKcrP5NjQLRq+QlnSHoECVUC0mu6gV7y6DOf f8Ow== X-Gm-Message-State: AJIora+QNcy9y3FVmH/jH2ShI2yeUdvatzCENH73sWI4luwHfVW9zLLb x5Z1X5BDawZYYIdlYBZ3YEgtM+2+sxXNcaxT X-Received: by 2002:a9d:5e16:0:b0:61c:82ef:1d96 with SMTP id d22-20020a9d5e16000000b0061c82ef1d96mr9310924oti.184.1658253633209; Tue, 19 Jul 2022 11:00:33 -0700 (PDT) Received: from stoup.. ([172.58.110.182]) by smtp.gmail.com with ESMTPSA id c25-20020a4ae259000000b0035eb4e5a6cesm6286747oot.36.2022.07.19.11.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 11:00:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Xiaojuan Yang Subject: [PULL 06/21] target/loongarch/op_helper: Fix coverity cond_at_most error Date: Tue, 19 Jul 2022 23:29:45 +0530 Message-Id: <20220719180000.378186-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220719180000.378186-1-richard.henderson@linaro.org> References: <20220719180000.378186-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Xiaojuan Yang The boundary size of cpucfg array should be 0 to ARRAY_SIZE(cpucfg)-1. So, using index bigger than max boundary to access cpucfg[] must be forbidden. Fix coverity CID: 1489760 Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220715060740.1500628-6-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/loongarch/op_helper.c b/target/loongarch/op_helper.c index 4b429b6699..568c071601 100644 --- a/target/loongarch/op_helper.c +++ b/target/loongarch/op_helper.c @@ -81,7 +81,7 @@ target_ulong helper_crc32c(target_ulong val, target_ulong m, uint64_t sz) target_ulong helper_cpucfg(CPULoongArchState *env, target_ulong rj) { - return rj > 21 ? 0 : env->cpucfg[rj]; + return rj >= ARRAY_SIZE(env->cpucfg) ? 0 : env->cpucfg[rj]; } uint64_t helper_rdtime_d(CPULoongArchState *env)