From patchwork Mon Jan 30 16:42:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1734281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=GeDJ3QtM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=YcnYhLLM; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P5DWF0Hvfz1yhq for ; Tue, 31 Jan 2023 03:42:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=EQ6cE8mRUtyIZ69dMu8B/tC+2P8ITuc6ct4+r+5HLIU=; b=GeDJ3QtMCwhNU9 gKkOyX0FX+OfEL5CAlbEpFGnDV6Tx9/70d+LkpyXsPi8mf45GRyDvJstc4o32iojkULJ9PMTXzNZP oRH/KeIZQVaeXAfgoObcutqV/S6OXuyq3I0oUYQY5QxBOaL++3EybbrFOuBpWfUHZ2srpy3WRZ2zz aqOw/+MooeLoQ3yNDetxU8WAH60S/zKlqN4IrVvJQKonQo21NGnrhSaVK9A0KgSzCrEsVZjLc6/Kw hADKN7ewuTHWOVOnPbiQtXgXmkY0H+wjRc28YJoyCh5YXG6Kq/XtmRkR5Z6NHxF2SzW2IcX3UB60W 0Kfa8zV229bd/23TWCuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMXEn-004HBw-GY; Mon, 30 Jan 2023 16:42:33 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMXEk-004HAN-UA for opensbi@lists.infradead.org; Mon, 30 Jan 2023 16:42:32 +0000 Received: by mail-wm1-x332.google.com with SMTP id n13so1440772wmr.4 for ; Mon, 30 Jan 2023 08:42:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3CvTxDPEFhqOL1qME0271bIVlW8Gg3RgU4cqFJfL1NI=; b=YcnYhLLMY4qSVrgHmEkflqKxH8LwrYcRiLMXTaCpimbwgsGe48IzAzd6pDRXazKOZd zxJpD7dAUd5K4pYRwsOHZl5wGVtjnn9tDzgq/dfXv8GEalOnZkAw+Cg6uofy27R27myh FT3b72+2SLCJhQg2R0OLTfZpczPUH1OuN/lqbWduBWxQs1uA118zjPFz7ufuwIc04+yY YBof/XmTRMGObrA087rUqW9h+O9DqIB8Lzc9KFT+PHiqPo9gVvBnCexnksg8iZwl6Z0D 6pbsPhOdmUiaYIpP42UEmcIP5JHgyo0TOnAo9y+kuP/Qh/2B8nN4E0N/9cz7fQoIhASQ EfrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3CvTxDPEFhqOL1qME0271bIVlW8Gg3RgU4cqFJfL1NI=; b=0RESL5NjERIiPeQP8EuSXGyAsHN/9TcIbh8TkokblPPYCGjzakVH56nSlT/2eh+5D5 0jGq14YJvYU0+GmZRHUG1Q8odfj0Dj1b7Rx9Jgf6dc3F+mzTg1bj0SjvgoxYVOp3faO2 +kpoxrlcgkQQ3YIxfQ4XJI1AxQU8efkk9g20n16iMN28ZP/faapEhAAQd0Iu/RXl4gIU ODoVOOhUip3/JoFqwhNpXECnPCwf6U3vaBS+2jeH1mxAbl3VOBPLTGeShl+yhi5r1Xvr +7hhEMt59pbEeLT8oUtIxJiHvnzPx7gSiJ6oeF5F9SRrXH28a+voA6p2ZOATQCDbHRfG kx1g== X-Gm-Message-State: AFqh2kowOOTGFsnrcr3kJQCPelQ2TWweLSIhmkhQKKQUk2aPTdn9S4OO /9IPHUOQSMvrUUAIDyqmrhWjdDDn3Et/q/ww X-Google-Smtp-Source: AMrXdXtuYlCGuSQP76khfOQjeRs2xXZECu22bq7b5VMNryhS5pYBnrBw0DIe1SDdR5QSuo0Q61k8lg== X-Received: by 2002:a05:600c:5d1:b0:3d0:761b:f86 with SMTP id p17-20020a05600c05d100b003d0761b0f86mr50891943wmd.28.1675096946169; Mon, 30 Jan 2023 08:42:26 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002bfd190fd60sm11528494wrr.108.2023.01.30.08.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 08:42:25 -0800 (PST) From: Andrew Jones To: opensbi@lists.infradead.org Cc: 'Anup Patel ' , 'Atish Patra ' Subject: [PATCH] lib: sbi: Ensure domidx_to_domain_table is null-terminated Date: Mon, 30 Jan 2023 17:42:24 +0100 Message-Id: <20230130164224.1364402-1-ajones@ventanamicro.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230130_084230_995143_635B1133 X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: sbi_domain_for_each() requires domidx_to_domain_table[] to be null-terminated. Allocate one extra element which will always be null. Signed-off-by: Andrew Jones --- lib/sbi/sbi_domain.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:332 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org sbi_domain_for_each() requires domidx_to_domain_table[] to be null-terminated. Allocate one extra element which will always be null. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- lib/sbi/sbi_domain.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 3ab1fbe0b7de..3813f1b2e97d 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -17,8 +17,12 @@ #include #include +/* + * We allocate an extra element because sbi_domain_for_each() expects + * the array to be null-terminated. + */ +struct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX + 1] = { 0 }; struct sbi_domain *hartid_to_domain_table[SBI_HARTMASK_MAX_BITS] = { 0 }; -struct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX] = { 0 }; static u32 domain_count = 0; static bool domain_finalized = false;