]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Update PXE driver to check for NULL pointer before use it.
authorFu Siyuan <siyuan.fu@intel.com>
Tue, 2 Jan 2018 05:25:59 +0000 (13:25 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Thu, 4 Jan 2018 01:07:48 +0000 (09:07 +0800)
This patch is to fix the issue that dereferencing of "This" (EFI_LOAD_FILE_PROTOCOL)
in EfiPxeLoadFile() is happening before the NULL check.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c

index dc77d256f8e97afdfe82e7ea06e9d0f9b952d600..93f3bfa5ba8dbf9128440f65193e009a59f0b9c3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This implementation of EFI_PXE_BASE_CODE_PROTOCOL and EFI_LOAD_FILE_PROTOCOL.\r
 \r
-  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -2349,26 +2349,22 @@ EfiPxeLoadFile (
   EFI_STATUS                  Status;\r
   EFI_STATUS                  MediaStatus;\r
 \r
-  if (FilePath == NULL || !IsDevicePathEnd (FilePath)) {\r
+  if (This == NULL || BufferSize == NULL || FilePath == NULL || !IsDevicePathEnd (FilePath)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   \r
-  VirtualNic = PXEBC_VIRTUAL_NIC_FROM_LOADFILE (This);\r
-  Private    = VirtualNic->Private;\r
-  PxeBc      = &Private->PxeBc;\r
-  UsingIpv6  = FALSE;\r
-  Status     = EFI_DEVICE_ERROR;\r
-\r
-  if (This == NULL || BufferSize == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
   //\r
   // Only support BootPolicy\r
   //\r
   if (!BootPolicy) {\r
     return EFI_UNSUPPORTED;\r
   }\r
+  \r
+  VirtualNic = PXEBC_VIRTUAL_NIC_FROM_LOADFILE (This);\r
+  Private    = VirtualNic->Private;\r
+  PxeBc      = &Private->PxeBc;\r
+  UsingIpv6  = FALSE;\r
+  Status     = EFI_DEVICE_ERROR;\r
 \r
   //\r
   // Check media status before PXE start\r