]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
MdeModulePkg/DxeCapsuleLibFmp: pass progress callback only if it works
[mirror_edk2.git] / MdeModulePkg / Library / DxeCapsuleLibFmp / DxeCapsuleLib.c
index f0226eafa57691be76e07cc1db6da36a5b716791..ab41df0eb0a4dd402e3e9d731a51a30ae30e4fd4 100644 (file)
@@ -841,6 +841,7 @@ SetFmpImageData (
   UINT8                                         *Image;\r
   VOID                                          *VendorCode;\r
   CHAR16                                        *AbortReason;\r
+  EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS ProgressCallback;\r
 \r
   Status = gBS->HandleProtocol(\r
                   Handle,\r
@@ -892,7 +893,11 @@ SetFmpImageData (
   //\r
   // Before calling SetImage(), reset the progress bar to 0%\r
   //\r
-  UpdateImageProgress (0);\r
+  ProgressCallback = UpdateImageProgress;\r
+  Status = UpdateImageProgress (0);\r
+  if (EFI_ERROR (Status)) {\r
+    ProgressCallback = NULL;\r
+  }\r
 \r
   Status = Fmp->SetImage(\r
                   Fmp,\r
@@ -900,13 +905,15 @@ SetFmpImageData (
                   Image,                                  // Image\r
                   ImageHeader->UpdateImageSize,           // ImageSize\r
                   VendorCode,                             // VendorCode\r
-                  UpdateImageProgress,                    // Progress\r
+                  ProgressCallback,                       // Progress\r
                   &AbortReason                            // AbortReason\r
                   );\r
   //\r
   // Set the progress bar to 100% after returning from SetImage()\r
   //\r
-  UpdateImageProgress (100);\r
+  if (ProgressCallback != NULL) {\r
+    UpdateImageProgress (100);\r
+  }\r
 \r
   DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status));\r
   if (AbortReason != NULL) {\r