audk/IntelFrameworkModulePkg/Library/GenericBdsLib
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
..
BdsBoot.c IntelFrameworkModulePkg: GenericBdsLib: set Status before use 2015-07-26 08:06:11 +00:00
BdsConnect.c Remove BdsLibConnectConsoleVariableWithoutDispatch() and enhance BdsLibConnectDevicePath() to only call gDS->Dispatch() when the current TPL is TPL_APPLICATION 2013-03-19 07:10:51 +00:00
BdsConsole.c IntelFrameworkModulePkg/SourceLevelDebugPkg: Fix the typo about word “hanlde” 2014-08-20 04:31:22 +00:00
BdsMisc.c IntelFrameworkModulePkg GenericBdsLib: Potential read over memory boudary 2015-07-13 01:22:21 +00:00
DevicePath.c Update all the code to consume the ConvertDevicePathToText, ConvertDevicePathNodeToText, ConvertTextToDevicePath and ConvertTextToDeviceNode APIs in DevicePathLib. 2013-07-26 03:14:08 +00:00
GenericBdsLib.inf IntelFrameworkModulePkg/GenericBdsLib: remove AcpiS3->S3Save() call 2015-07-26 08:02:19 +00:00
GenericBdsLib.uni IntelFrameworkModulePkg: Convert non DOS format files to DOS format 2014-09-03 08:45:37 +00:00
GenericBdsStrings.uni Fix the BDS to show UEFI hard drive boot option as "EFI Hard Drive" instead of "EFI DVD/CDROM" 2011-07-05 07:55:45 +00:00
InternalBdsLib.h IntelFrameworkModulePkg/GenericBdsLib: remove AcpiS3->S3Save() call 2015-07-26 08:02:19 +00:00
Performance.c IntelFrameworkModulePkg GenericBdsLib: Resolve array size mismatch 2015-07-07 06:13:53 +00:00
String.c Update the copyright notice format 2010-04-23 16:28:26 +00:00
String.h Update the copyright notice format 2010-04-23 16:28:26 +00:00