]> git.proxmox.com Git - mirror_edk2.git/commitdiff
FmpDevicePkg FmpDxe: Check ImageIndex first before Image/ImageSize
authorStar Zeng <star.zeng@intel.com>
Sat, 28 Jul 2018 01:22:03 +0000 (09:22 +0800)
committerKinney, Michael D <michael.d.kinney@intel.com>
Thu, 2 Aug 2018 21:46:19 +0000 (14:46 -0700)
It does not make sense to check the Image/ImageSize if ImageIndex
has been invalid.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
FmpDevicePkg/FmpDxe/FmpDxe.c

index eb452737543ec1585f985b976700e72e3cd41f87..94fdf5608529c63254249c446584f29a88b004d5 100644 (file)
@@ -497,6 +497,15 @@ GetTheImage (
 \r
   Status = EFI_SUCCESS;\r
 \r
 \r
   Status = EFI_SUCCESS;\r
 \r
+  //\r
+  // Check to make sure index is 1 (only 1 image for this device)\r
+  //\r
+  if (ImageIndex != 1) {\r
+    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));\r
+    Status = EFI_INVALID_PARAMETER;\r
+    goto cleanup;\r
+  }\r
+\r
   if ((ImageSize == NULL)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is NULL.\n"));\r
     Status = EFI_INVALID_PARAMETER;\r
   if ((ImageSize == NULL)) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is NULL.\n"));\r
     Status = EFI_INVALID_PARAMETER;\r
@@ -523,16 +532,6 @@ GetTheImage (
     goto cleanup;\r
   }\r
 \r
     goto cleanup;\r
   }\r
 \r
-  //\r
-  // Check to make sure index is 1 (only 1 image for this device)\r
-  //\r
-  if (ImageIndex != 1) {\r
-    DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n"));\r
-    Status = EFI_INVALID_PARAMETER;\r
-    goto cleanup;\r
-  }\r
-\r
-\r
   Status = FmpDeviceGetImage (Image, ImageSize);\r
 cleanup:\r
 \r
   Status = FmpDeviceGetImage (Image, ImageSize);\r
 cleanup:\r
 \r