From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web08.7110.1611236875300356717 for ; Thu, 21 Jan 2021 05:47:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Fq542kJR; spf=pass (domain: redhat.com, ip: 63.128.21.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611236874; 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=eVarJ8ZQiw3cvP2v37MEUbPEDVeFn6/+eNICF3hHnvs=; b=Fq542kJR5lqQDGW/jIUvN1R/7lx0T8CKVlkOWs+hfMHj7IBxOpaSWkhAt2qNAF4TuyjDrB dTAdf7GPQwJ3NSnBle0Q96Qw/FZuT5CyaHhEAmtL+hNqwxyyFErA+Gl4S11XrZtIdPsBl2 0tKHOkl32ruPa81jYLrbadFNZ1fr6Ts= 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-578-fvv6nzZ6N82kDSo420FNXQ-1; Thu, 21 Jan 2021 08:47:50 -0500 X-MC-Unique: fvv6nzZ6N82kDSo420FNXQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74648107ACE3; Thu, 21 Jan 2021 13:47:49 +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 38E185F9B5; Thu, 21 Jan 2021 13:47:47 +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: Date: Thu, 21 Jan 2021 14:47:47 +0100 MIME-Version: 1.0 In-Reply-To: <20210121093944.1621-1-star.zeng@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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. Oops, sorry! > 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?". :) Indeed I don't know why none of the toolchains caught this issue in CI. :/ GCC is otherwise known for its "variable may be used without initialization" warnings. > > 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); > Reviewed-by: Laszlo Ersek (Also, I think Ray's R-b from applies here, so I'm going to pick that up.) Thanks & sorry again Laszlo