]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FmpDevicePkg/FmpDxe/FmpDxe.c
FmpDevicePkg/FmpDxe: Update FmpDeviceCheckImageWithStatus() handling
[mirror_edk2.git] / FmpDevicePkg / FmpDxe / FmpDxe.c
index 197df28c8dd6c3691bb9d57eb2ea74d2b0eaece1..1e7ec4a09e1611c9bef2abe6170d1fa699664e86 100644 (file)
@@ -1040,8 +1040,19 @@ CheckTheImageInternal (
   //\r
   Status = FmpDeviceCheckImageWithStatus ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);\r
   if (EFI_ERROR (Status)) {\r
+    // The image cannot be valid if an error occurred checking the image\r
+    if (*ImageUpdatable == IMAGE_UPDATABLE_VALID) {\r
+      *ImageUpdatable = IMAGE_UPDATABLE_INVALID;\r
+    }\r
+\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status));\r
+  }\r
 \r
+  //\r
+  // Only validate the library last attempt status code if the image is not updatable.\r
+  // This specifically avoids converting LAST_ATTEMPT_STATUS_SUCCESS if it set for an updatable image.\r
+  //\r
+  if (*ImageUpdatable != IMAGE_UPDATABLE_VALID) {\r
     //\r
     // LastAttemptStatus returned from the device library should fall within the designated error range\r
     // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]\r
@@ -1049,12 +1060,12 @@ CheckTheImageInternal (
     if ((*LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||\r
         (*LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE))\r
     {\r
-      DEBUG (\r
-        (DEBUG_ERROR,\r
-         "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",\r
-         mImageIdName,\r
-         *LastAttemptStatus)\r
-        );\r
+      DEBUG ((\r
+        DEBUG_ERROR,\r
+        "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",\r
+        mImageIdName,\r
+        *LastAttemptStatus\r
+        ));\r
       *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;\r
     }\r
   }\r