X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Nt32Pkg%2FWinNtBusDriverDxe%2FWinNtBusDriver.c;h=f4b7e1ba15f06b28e2463a26e68469f807e4a407;hb=4d5d7812786db947e476b4d850698b465d0e2d99;hp=86d7929671cf343339582e1c9375ce5a8a69e891;hpb=3d6b07b6ece195c8d99c7aa3a9db7fd8383c5ada;p=mirror_edk2.git diff --git a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c index 86d7929671..f4b7e1ba15 100644 --- a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c +++ b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c @@ -1,13 +1,8 @@ /**@file -Copyright (c) 2006 - 2007, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+(C) Copyright 2018 Hewlett Packard Enterprise Development LP
+SPDX-License-Identifier: BSD-2-Clause-Patent Module Name: @@ -239,20 +234,30 @@ Returns: // it is a legal Device Path Node for this bus driver's children. // if (RemainingDevicePath != NULL) { - if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH || - RemainingDevicePath->SubType != HW_VENDOR_DP || - DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) { - return EFI_UNSUPPORTED; - } - - for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) { - if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) { - break; + // + // Check if RemainingDevicePath is the End of Device Path Node, + // if yes, go on checking other conditions + // + if (!IsDevicePathEnd (RemainingDevicePath)) { + // + // If RemainingDevicePath isn't the End of Device Path Node, + // check its validation + // + if (RemainingDevicePath->Type != HARDWARE_DEVICE_PATH || + RemainingDevicePath->SubType != HW_VENDOR_DP || + DevicePathNodeLength(RemainingDevicePath) != sizeof(WIN_NT_VENDOR_DEVICE_PATH_NODE)) { + return EFI_UNSUPPORTED; + } + + for (Index = 0; Index < NT_PCD_ARRAY_SIZE; Index++) { + if (CompareGuid (&((VENDOR_DEVICE_PATH *) RemainingDevicePath)->Guid, mPcdEnvironment[Index].DevicePathGuid)) { + break; + } + } + + if (Index >= NT_PCD_ARRAY_SIZE) { + return EFI_UNSUPPORTED; } - } - - if (Index >= NT_PCD_ARRAY_SIZE) { - return EFI_UNSUPPORTED; } } @@ -261,8 +266,8 @@ Returns: // Status = gBS->OpenProtocol ( ControllerHandle, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath, + &gEfiWinNtThunkProtocolGuid, + (VOID **) &WinNtThunk, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER @@ -275,17 +280,23 @@ Returns: return Status; } + // + // Close the I/O Abstraction(s) used to perform the supported test + // gBS->CloseProtocol ( ControllerHandle, - &gEfiDevicePathProtocolGuid, + &gEfiWinNtThunkProtocolGuid, This->DriverBindingHandle, ControllerHandle ); + // + // Open the EFI Device Path protocol needed to perform the supported test + // Status = gBS->OpenProtocol ( ControllerHandle, - &gEfiWinNtThunkProtocolGuid, - (VOID **) &WinNtThunk, + &gEfiDevicePathProtocolGuid, + (VOID **) &ParentDevicePath, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER @@ -307,11 +318,11 @@ Returns: } // - // Close the I/O Abstraction(s) used to perform the supported test + // Close protocol, don't use device path protocol in the Support() function // gBS->CloseProtocol ( ControllerHandle, - &gEfiWinNtThunkProtocolGuid, + &gEfiDevicePathProtocolGuid, This->DriverBindingHandle, ControllerHandle ); @@ -437,7 +448,7 @@ Returns: ASSERT (PcdTempStr != NULL); TempStrSize = StrLen (PcdTempStr); - TempStr = AllocateMemory ((TempStrSize * sizeof (CHAR16)) + 1); + TempStr = AllocateMemory (((TempStrSize + 1) * sizeof (CHAR16))); StrCpy (TempStr, PcdTempStr); StartString = TempStr; @@ -470,15 +481,25 @@ Returns: CreateDevice = TRUE; if (RemainingDevicePath != NULL) { CreateDevice = FALSE; - Node = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath; - if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH && - Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP && - DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE) - ) { - if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) && - Node->Instance == Count + // + // Check if RemainingDevicePath is the End of Device Path Node, + // if yes, don't create any child device + // + if (!IsDevicePathEnd (RemainingDevicePath)) { + // + // If RemainingDevicePath isn't the End of Device Path Node, + // check its validation + // + Node = (WIN_NT_VENDOR_DEVICE_PATH_NODE *) RemainingDevicePath; + if (Node->VendorDevicePath.Header.Type == HARDWARE_DEVICE_PATH && + Node->VendorDevicePath.Header.SubType == HW_VENDOR_DP && + DevicePathNodeLength (&Node->VendorDevicePath.Header) == sizeof (WIN_NT_VENDOR_DEVICE_PATH_NODE) ) { - CreateDevice = TRUE; + if (CompareGuid (&Node->VendorDevicePath.Guid, mPcdEnvironment[Index].DevicePathGuid) && + Node->Instance == Count + ) { + CreateDevice = TRUE; + } } } }