Revision: 18061
          http://sourceforge.net/p/edk2/code/18061
Author:   jljusten
Date:     2015-07-26 08:06:11 +0000 (Sun, 26 Jul 2015)
Log Message:
-----------
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 <[email protected]>
Cc: Jeff Fan <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
Reviewed-by: Jeff Fan <[email protected]>

Modified Paths:
--------------
    trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c

Modified: trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
===================================================================
--- trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c  
2015-07-26 08:06:05 UTC (rev 18060)
+++ trunk/edk2/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c  
2015-07-26 08:06:11 UTC (rev 18061)
@@ -2236,6 +2236,7 @@
   LIST_ENTRY                TempBootLists;
   EFI_BOOT_LOGO_PROTOCOL    *BootLogo;
 
+  Status        = EFI_SUCCESS;
   *ExitDataSize = 0;
   *ExitData     = NULL;
 


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to