From patchwork Thu Jun 9 12:12:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12875480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08E25C43334 for ; Thu, 9 Jun 2022 12:20:01 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=NM8bttOLkfCcJmzHNbT0fzAmZYEPOdkOBb7bJ1KtGbA=; b=jS46L9j0GZoBYv KM81Af35bNrGmMtpcBrrGBU79YQjrRaXUyWbQIuQdD/uPDIbPI5YutgAuahoLl6k1htKkfd3P+K45 7tdl1RxUGlirPr9DQbnRvj7r8bAfptPF41WEMsvSFtXU5klNkNBtGt6GLnajp80y9shed0v+GwZKa 14XNQ6ZFy3eGZcdrwg+1bO7Q1fJCr7EvIrz9pWjUNGpGJdOa6CNqJI3A6gpylWabbOnEaYRRDbgUA QwoJLgHDuwtz1zEL6k5KDfVLp/wCgzpSAaSTYan+/i5+zW0QR/Or9MDO1s91nZkM263nD49EiO1Vt cGihYtVZLJb2KSfs40Kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzH7g-001fkJ-PA; Thu, 09 Jun 2022 12:18:49 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzH1f-001cmP-JO for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2022 12:12:37 +0000 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 ED65460C34; Thu, 9 Jun 2022 12:12:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 203F1C3411B; Thu, 9 Jun 2022 12:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654776751; bh=ZP2LKc+PqJhpwgOwUSWwHxASOb1EzEUlXbWANnogBiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gbKa9PIgEEgAia+jihKaV+0Wfz476xjKqSwKu10ioqCXh4033dEaMFOO9Udwv9U1K XBDmdpj7g0S07SzgOLdxpWNRcLUlwrdLeKnXJnAT1c0SpYIvvHWPFvrBLOhSMzyhJU SsbVcwZ4KA5Dm2h4wi9m3ZFlBIWYRsNWVSwT05dJIM8epRXEz4gPgWLsdRZoIJn7km cEUvLaGIChB6yQTePYU1fLcmUZ6+qCLCdFh+sYTW2/C7WoZovmoveC+tRr8v4amwXH miKHD3YqwpPATxVi0DxURYMTWjDmAk0rQI6wYCPtT+rD62fdx716VidMFDC9lCR8/b 1a61Fasj9wXug== From: Will Deacon To: kvmarm@lists.cs.columbia.edu Cc: Will Deacon , Marc Zyngier , Alexandru Elisei , kernel-team@android.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/6] KVM: arm64: Return error from kvm_arch_init_vm() on allocation failure Date: Thu, 9 Jun 2022 13:12:18 +0100 Message-Id: <20220609121223.2551-2-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220609121223.2551-1-will@kernel.org> References: <20220609121223.2551-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_051235_716670_A57104AE X-CRM114-Status: GOOD ( 12.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If we fail to allocate the 'supported_cpus' cpumask in kvm_arch_init_vm() then be sure to return -ENOMEM instead of success (0) on the failure path. Reviewed-by: Alexandru Elisei Signed-off-by: Will Deacon --- arch/arm64/kvm/arm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 400bb0fe2745..0da0f06037db 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -150,8 +150,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) if (ret) goto out_free_stage2_pgd; - if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL)) + if (!zalloc_cpumask_var(&kvm->arch.supported_cpus, GFP_KERNEL)) { + ret = -ENOMEM; goto out_free_stage2_pgd; + } cpumask_copy(kvm->arch.supported_cpus, cpu_possible_mask); kvm_vgic_early_init(kvm);