From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.18112.1678452537284029869 for ; Fri, 10 Mar 2023 04:49:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZwWBZjvQ; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678452536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q51V72Rusis+io2+7XX6lk7o/pXZnD4RB0/AiRTCxrg=; b=ZwWBZjvQYCQApqMOUJkyBBJIufrsi0Ld9qcxL5wAhRFexflTlC9PHth1txF1TmBs1hfbJ8 WjRs7q0ETbyk54+H71G3lbHNSRajBcnge1eZqqCImHdCY05+Oi1ZSWtwR2lp80N6ZKj73D OYsFkynrp2DCgKzsrikm5753da+P2ec= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-2JQWdm4hMK6WNpkRdqFLAg-1; Fri, 10 Mar 2023 07:48:53 -0500 X-MC-Unique: 2JQWdm4hMK6WNpkRdqFLAg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5F2A299E752; Fri, 10 Mar 2023 12:48:52 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75D5C492C3E; Fri, 10 Mar 2023 12:48:52 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 892EB1800990; Fri, 10 Mar 2023 13:48:49 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ray Ni , Oliver Steffen , Gerd Hoffmann , Rahul Kumar , Pawel Polawski , Eric Dong Subject: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: fix error handling Date: Fri, 10 Mar 2023 13:48:49 +0100 Message-Id: <20230310124849.831839-3-kraxel@redhat.com> In-Reply-To: <20230310124849.831839-1-kraxel@redhat.com> References: <20230310124849.831839-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true ASSERT() is not proper handling of allocation failures, it gets compiled out on RELEASE builds. Print a message and enter dead loop instead. Signed-off-by: Gerd Hoffmann --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 55a9f79da8eb..2e41df1f1074 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -879,6 +879,12 @@ PiCpuSmmEntry ( // BufferPages = EFI_SIZE_TO_PAGES (SIZE_32KB + TileSize * (mMaxNumberOfCpus - 1)); Buffer = AllocateAlignedCodePages (BufferPages, SIZE_4KB); + if (!Buffer) { + DEBUG ((DEBUG_ERROR, "Failed to allocate %d pages.\n", BufferPages)); + CpuDeadLoop (); + return EFI_OUT_OF_RESOURCES; + } + ASSERT (Buffer != NULL); DEBUG ((DEBUG_INFO, "New Allcoated SMRAM SaveState Buffer (0x%08x, 0x%08x)\n", Buffer, EFI_PAGES_TO_SIZE (BufferPages))); } -- 2.39.2