From patchwork Tue Jul 19 17:59:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 591663 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp4210267max; Tue, 19 Jul 2022 11:05:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLeyl1eDpF8oagEzf54Sns2PCXeOQ0P2fpq9kJzZw88BRSR0MWwEKBRDpQgkAQgLt8O5gK X-Received: by 2002:ac8:5e4e:0:b0:31f:40b:35c7 with SMTP id i14-20020ac85e4e000000b0031f040b35c7mr1639879qtx.244.1658253911019; Tue, 19 Jul 2022 11:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658253911; cv=none; d=google.com; s=arc-20160816; b=w6YH/eGrQKlJ/XKlKwHs2k7jlCx+Q9GZtNigbfRfmkoCN/ize2XvE4j+EGSGcyQDbH wPWkM4vk1TSn3VtShHWNEMDkQNcnzHZg3T3LMEATmE2rgCXM5zRdOgyz7oeKcKLegVDI 4o3FJ/6FFN2pXx3qwD7wzrMj3npAsH9y9XpgT+8yUBMJ/f/oKHgF7/5Zx5uHsE2aZzsj r1VpR8p339CeYLy7YQJnfAatdzSEyid1tGmIg1tecEBKHzz3Ufmb4A0+16fbVgUS4URc mKOZZf5e/6XTxQQKY2lrqMv8Iq0Vs1QH+CjAUha9u1tTKiaXF3HXPP7PH9ACeeOD20Rb 14bg== 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=jY3a70HYN9nK0tMErtaVJBwYrjq2ULedvsEhArnyW7M=; b=cqvpOibDmk6wmsGwRes1qXTYwgUB7KC47GPZ9KWYKjFrGRjouG8s8gwnvRW+kS6cG3 BMccM8du5TxwMetqBtoxbuIdDe+tJc9NYDh+tJogsQgZJy8cUiU/nr68ja52x5U5PDcr LndkAnzHS+U3g3jCJaOJXAVQUN7WMujyUxLSZBTOB/X9Xy4ZI2sQuJDXWuOTdtQTzb1+ qdCHTg6b2Nt0pj9NUd0F8GNSN4WQ6O4wUUtIOwDlD5FIiA/+YPUCnB+6yG4tB7tLVApn qFBh6oVhPxMjG2vrSsu/GRdpxiti58CN6tqWtIKnAxE7Pgc2x8tgcDQ4abfPlR9/3HGb eRSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jcMMx26Z; 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 y9-20020ac85f49000000b0031f018bfe1asi928629qta.71.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=jcMMx26Z; 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]:60010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDrao-0002so-Gu for patch@linaro.org; Tue, 19 Jul 2022 14:05:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDrWF-0005ti-6B for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:00:27 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]:41788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDrWD-0006AB-Ht for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:00:26 -0400 Received: by mail-ot1-x332.google.com with SMTP id w6-20020a056830410600b0061c99652493so7068366ott.8 for ; Tue, 19 Jul 2022 11:00:25 -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=jY3a70HYN9nK0tMErtaVJBwYrjq2ULedvsEhArnyW7M=; b=jcMMx26Z6g048x9DYHHLU5R5s+rrtmzAQ+ohWrHs9d8jwJcLYB8newzWwxkDrgoPzI Rrp6mxQ5ztNFlf5e4uETt82VlGYqfYF5Y4neFcyZ2TRPe/fy0avbG2US95gJ4amu1bFT 6RxaSG8puIP/e/keCrElvI+K1W7zMaT+qY81bK56mByVPsz6hl1eCmJtKwIj3rVwxR43 pRNPyKmXxaD7dOGNvijMC1jhowAcBNULgeZ0ieQwW4AxMOFW0ueSI9Px9ApjuxXuYBXp ixfER6H9e0uWWvf7sDAemMhUiv4TnHf/7Ldy50ner+6YBxinVM9xY1XUXFZuEN1HJyFu 9rfA== 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=jY3a70HYN9nK0tMErtaVJBwYrjq2ULedvsEhArnyW7M=; b=q1qFqLZJ26Xwr7l0xmYAxrje4K7vJfC4rZ6BXj3pHrpcBUpONM/JbEwyZkjJLkMzAU SJCypbk5eI7MDCAbfgUiv9omY8iyHBOHNi+Vn/5rg48Pl4cEV1ywemmj7OxJRxzXAghC 1JWlg3Il3yHRhEvprHEJII8LdnefZ3FU9jWcDKJN4R80TGmo1AZJj4B6+AvKVf/Lypf6 Qj4Q4rRDSF2fFbqI0i1bWCqeFdjxmaTSoPwxciAXCgKBFQOoKm1+A+KOYvxk/Nb0G05k PuvdU2mCH/fMeQGrbumxhslDt5PQyR1qbThi67UkvJJt92e2IZ0Mshze+p7G0pc4IUeG aGFw== X-Gm-Message-State: AJIora9IlC6FdGK14LFYwqwKqiOr6hPZfUyZyPEU7yAe53W+YCd7pA/q Wa7VuK/9eJDn3lXojvqrw8+eGXqaU4+bZVjd X-Received: by 2002:a05:6830:4a5:b0:61c:b012:faa0 with SMTP id l5-20020a05683004a500b0061cb012faa0mr2896294otd.46.1658253624893; Tue, 19 Jul 2022 11:00:24 -0700 (PDT) Received: from stoup.. ([172.58.110.182]) by smtp.gmail.com with ESMTPSA id c25-20020a4ae259000000b0035eb4e5a6cesm6286747oot.36.2022.07.19.11.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 11:00:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Xiaojuan Yang Subject: [PULL 04/21] target/loongarch/cpu: Fix coverity errors about excp_names Date: Tue, 19 Jul 2022 23:29:43 +0530 Message-Id: <20220719180000.378186-5-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::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.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 Fix out-of-bounds errors when access excp_names[] array. the valid boundary size of excp_names should be 0 to ARRAY_SIZE(excp_names)-1. However, the general code do not consider the max boundary. Fix coverity CID: 1489758 Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220715060740.1500628-4-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 5573468a7d..0d49ce68e4 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -140,7 +140,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) if (cs->exception_index != EXCCODE_INT) { if (cs->exception_index < 0 || - cs->exception_index > ARRAY_SIZE(excp_names)) { + cs->exception_index >= ARRAY_SIZE(excp_names)) { name = "unknown"; } else { name = excp_names[cs->exception_index]; @@ -190,8 +190,8 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) cause = cs->exception_index; break; default: - qemu_log("Error: exception(%d) '%s' has not been supported\n", - cs->exception_index, excp_names[cs->exception_index]); + qemu_log("Error: exception(%d) has not been supported\n", + cs->exception_index); abort(); }