audk/IntelFrameworkModulePkg/Library
Laszlo Ersek 1999fb3180 IntelFrameworkModulePkg: GenericBdsLib: set Status before use
The recent patch titled

  IntelFrameworkModulePkg/GenericBdsLib: remove AcpiS3->S3Save() call

has exposed a preexistent bug in the BdsLibBootViaBootOption() function,
and now the IA32 build of OVMF fails with:

  In function 'BdsLibBootViaBootOption':
  error: 'Status' may be used uninitialized in this function

Namely, we have the following (simplified) data flow:

  //
  // Status and ImageHandle both start out uninitialized
  //

  /* ... */
  ImageHandle = BdsExpandUsbShortFormDevicePath (DevicePath);
  /* ... */

  if (ImageHandle == NULL) {
    /* ... */
  }
  if ((ImageHandle == NULL) || (EFI_ERROR(Status))) {
    /* ... */
  */

If BdsExpandUsbShortFormDevicePath() returns a non-NULL value, then the
second "if" statement will check Status without the function having
initialized or assigned it.

When BdsExpandUsbShortFormDevicePath() returns non-NULL, Status should be
EFI_SUCCESS; so let us assign it that value up-front.

Note that the bug existed before the patch

  IntelFrameworkModulePkg/GenericBdsLib: remove AcpiS3->S3Save() call

That is, the bug was not introduced, only exposed, by the patch -- in the
pre-patch state, although the Status variable was set early and
unconditionally, the error code that it may have carried from the failed
gEfiAcpiS3SaveProtocolGuid lookup had nothing to do with the second "if"
statement above.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18061 6f19259b-4bc3-4df7-8a09-765794883524
2015-07-26 08:06:11 +00:00
..
BaseUefiTianoCustomDecompressLib IntelFrameworkModulePkg: Fix typo. 2015-03-13 08:05:02 +00:00
DxeCapsuleLib Refine the format of GUID in INF files for IntelFrameworkModulePkg. 2015-01-16 02:23:07 +00:00
DxeReportStatusCodeLibFramework IntelFrameworkModulePkg: Convert non DOS format files to DOS format 2014-09-03 08:45:37 +00:00
GenericBdsLib IntelFrameworkModulePkg: GenericBdsLib: set Status before use 2015-07-26 08:06:11 +00:00
LegacyBootManagerLib IntelFrameworkModulePkg: Add LegacyBootManagerLib. 2015-05-06 04:50:23 +00:00
LzmaCustomDecompressLib IntelFrameworkModulePkg: Move LzmaDecompress GUID 2015-04-03 02:49:10 +00:00
PeiDxeDebugLibReportStatusCode IntelFrameworkModulePkg PeiDxeDebugLib: Use safe string functions 2015-06-30 06:26:20 +00:00
PeiRecoveryLib IntelFrameworkModulePkg: Convert non DOS format files to DOS format 2014-09-03 08:45:37 +00:00
PeiS3Lib IntelFrameworkModulePkg: Convert non DOS format files to DOS format 2014-09-03 08:45:37 +00:00
PlatformBdsLibNull Removes dead code from the PlatformBdsLibNull,leaving this unused code might confuse the user. 2014-10-14 06:30:17 +00:00
SmmRuntimeDxeReportStatusCodeLibFramework IntelFrameworkModulePkg: Convert non DOS format files to DOS format 2014-09-03 08:45:37 +00:00