From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Fri, 12 Apr 2019 16:31:46 -0700 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D93CA3082A4C; Fri, 12 Apr 2019 23:31:45 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-65.rdu2.redhat.com [10.10.120.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id C558C6090C; Fri, 12 Apr 2019 23:31:44 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [PATCH 07/10] OvmfPkg/AcpiPlatformDxe: suppress invalid "deref of undef pointer" warning Date: Sat, 13 Apr 2019 01:31:25 +0200 Message-Id: <20190412233128.4756-8-lersek@redhat.com> In-Reply-To: <20190412233128.4756-1-lersek@redhat.com> References: <20190412233128.4756-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 12 Apr 2019 23:31:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable RH covscan emits the following false positive: > Error: CLANG_WARNING: > edk2-89910a39dcfd/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c:182:14: > warning: Dereference of undefined pointer value > # Status =3D FwVol->ReadSection ( > # ^~~~~~~~~~~~~~~~~~ > edk2-89910a39dcfd/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c:164:7: note: > Assuming the condition is false > # if (QemuDetected ()) { > # ^~~~~~~~~~~~~~~ > edk2-89910a39dcfd/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c:164:3: note: > Taking false branch > # if (QemuDetected ()) { > # ^ > edk2-89910a39dcfd/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c:174:3: note: > Taking false branch > # if (EFI_ERROR (Status)) { > # ^ > edk2-89910a39dcfd/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c:180:10: note: > Assuming 'Status' is equal to EFI_SUCCESS > # while (Status =3D=3D EFI_SUCCESS) { > # ^~~~~~~~~~~~~~~~~~~~~ > edk2-89910a39dcfd/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c:180:3: note: > Loop condition is true. Entering loop body > # while (Status =3D=3D EFI_SUCCESS) { > # ^ > edk2-89910a39dcfd/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c:182:14: note: > Dereference of undefined pointer value > # Status =3D FwVol->ReadSection ( > # ^~~~~~~~~~~~~~~~~~ > # 180| while (Status =3D=3D EFI_SUCCESS) { > # 181| > # 182|-> Status =3D FwVol->ReadSection ( > # 183| FwVol, > # 184| (EFI_GUID*)PcdGetPtr (PcdAcpiTableStora= geFile), This is invalid because LocateFvInstanceWithTables() sets FwVol on success. Suppress the message by: - assigning FwVol NULL first (this would replace the original report with "nullptr deref"), - asserting that FwVol is no longer NULL, on success. What's important here is that ASSERT() ends with ANALYZER_UNREACHABLE() o= n failure. Cc: Ard Biesheuvel Cc: Jordan Justen Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1710 Issue: scan-0991.txt Signed-off-by: Laszlo Ersek --- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/AcpiPlatfor= mDxe/AcpiPlatform.c index f2c49953950b..2b529d58a15c 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c @@ -156,23 +156,30 @@ InstallOvmfFvTables ( TableHandle =3D 0; =20 if (QemuDetected ()) { TableInstallFunction =3D QemuInstallAcpiTable; } else { TableInstallFunction =3D InstallAcpiTable; } =20 + // + // set FwVol (and use an ASSERT() below) to suppress incorrect + // compiler/analyzer warnings + // + FwVol =3D NULL; // // Locate the firmware volume protocol // Status =3D LocateFvInstanceWithTables (&FwVol); if (EFI_ERROR (Status)) { return EFI_ABORTED; } + ASSERT (FwVol !=3D NULL); + // // Read tables from the storage file. // while (Status =3D=3D EFI_SUCCESS) { =20 Status =3D FwVol->ReadSection ( FwVol, (EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile), --=20 2.19.1.3.g30247aa5d201