From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web10.23.1611239911522312333 for ; Thu, 21 Jan 2021 06:38:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UAOXQ2jX; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611239910; 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=M8fFJqCwNtwSS3oAexFNt8KQaCHmjhF2LG1dFtrb6LU=; b=UAOXQ2jXua0yHlWgLoGrVtJqnU1G9so2qQaO0RmF7hN+PTtUKoy9QOgxO/PCmQty9r+MgH H8kNtE+5gW2nMWtbCy46aoLXa8yrXyOjSOQNCddfdEUoOUPsLZBbDJA2XDmNqOw8y4E2b1 HgNJGOGhVKoLAUgR4iTXBAP4WY99X60= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-603-W1pB2roCODWQlKqsCH311w-1; Thu, 21 Jan 2021 09:38:26 -0500 X-MC-Unique: W1pB2roCODWQlKqsCH311w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 962A487950E; Thu, 21 Jan 2021 14:38:25 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-169.ams2.redhat.com [10.36.115.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83B4E100238C; Thu, 21 Jan 2021 14:38:24 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: NumberOfCpus may be uninitialized To: devel@edk2.groups.io, star.zeng@intel.com Cc: Eric Dong , Ray Ni References: <20210121093944.1621-1-star.zeng@intel.com> From: "Laszlo Ersek" Message-ID: <739d840f-eacb-c76d-1342-3457e6775d67@redhat.com> Date: Thu, 21 Jan 2021 15:38:23 +0100 MIME-Version: 1.0 In-Reply-To: <20210121093944.1621-1-star.zeng@intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 01/21/21 10:39, Zeng, Star wrote: > NumberOfCpus local variable in GetAcpiCpuData will be uninitialized > when CpuS3DataDxe runs before DxeRegisterCpuFeaturesLib (linked by > CpuFeaturesDxe) because there is no code to initialize it at > (AcpiCpuData != NULL) execution path. > > The issue is exposed after cefad282fb31aff3e1a6dcbd368cbbffc3fce900 > and 38ee7bafa72f58982f99ac6f61eef160f80bad69. > There was negligence in that code review. > One further topic may be "Could EDK2 CI be enhanced to catch this kind > of uninitialized local variable case?". :) > > This patch fixes this regression issue. > > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Signed-off-by: Star Zeng > --- > .../Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c > index 7bb92404027f..60daa5cc87f0 100644 > --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c > +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c > @@ -957,6 +957,7 @@ GetAcpiCpuData ( > // > // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs > // > + NumberOfCpus = AcpiCpuData->NumberOfCpus; > TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); > RegisterTable = AllocatePages (EFI_SIZE_TO_PAGES (TableSize)); > ASSERT (RegisterTable != NULL); > Merged as commit 6c5801be6ef3, via . I've picked up Ray's R-b from the detached message . I've also updated the original ticket: . Thanks & sorry about the regression, Laszlo