From 40d7a9cfaa529a8ed50a039719c09c42e05c496f Mon Sep 17 00:00:00 2001 From: jcarsey Date: Mon, 4 Oct 2010 16:25:24 +0000 Subject: fix a misspelling. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10905 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Include/Library/HandleParsingLib.h | 4 +-- .../UefiHandleParsingLib/UefiHandleParsingLib.c | 35 +++++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ShellPkg/Include/Library/HandleParsingLib.h b/ShellPkg/Include/Library/HandleParsingLib.h index f08768c152..b8166ff76f 100644 --- a/ShellPkg/Include/Library/HandleParsingLib.h +++ b/ShellPkg/Include/Library/HandleParsingLib.h @@ -321,7 +321,7 @@ ConvertHandleIndexToHandle( **/ EFI_HANDLE* EFIAPI -GetHandleListByPotocol ( +GetHandleListByProtocol ( IN CONST EFI_GUID *ProtocolGuid OPTIONAL ); @@ -335,7 +335,7 @@ GetHandleListByPotocol ( **/ EFI_HANDLE* EFIAPI -GetHandleListByPotocolList ( +GetHandleListByProtocolList ( IN CONST EFI_GUID **ProtocolGuids ); diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c index c398618bbb..107b3354e5 100644 --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c @@ -1116,7 +1116,7 @@ ParseHandleDatabaseForChildControllers( return Status; } - HandleBufferForReturn = GetHandleListByPotocol(&gEfiDriverBindingProtocolGuid); + HandleBufferForReturn = GetHandleListByProtocol(&gEfiDriverBindingProtocolGuid); if (HandleBufferForReturn == NULL) { FreePool (DriverBindingHandleBuffer); return Status; @@ -1311,7 +1311,7 @@ ParseHandleDatabaseForChildDevices( **/ EFI_HANDLE* EFIAPI -GetHandleListByPotocol ( +GetHandleListByProtocol ( IN CONST EFI_GUID *ProtocolGuid OPTIONAL ) { @@ -1329,6 +1329,9 @@ GetHandleListByPotocol ( Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList); if (Status == EFI_BUFFER_TOO_SMALL) { HandleList = AllocatePool(Size + sizeof(EFI_HANDLE)); + if (HandleList == NULL) { + return (NULL); + } Status = gBS->LocateHandle(AllHandles, NULL, NULL, &Size, HandleList); HandleList[Size/sizeof(EFI_HANDLE)] = NULL; } @@ -1336,6 +1339,9 @@ GetHandleListByPotocol ( Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList); if (Status == EFI_BUFFER_TOO_SMALL) { HandleList = AllocatePool(Size + sizeof(EFI_HANDLE)); + if (HandleList == NULL) { + return (NULL); + } Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)ProtocolGuid, NULL, &Size, HandleList); HandleList[Size/sizeof(EFI_HANDLE)] = NULL; } @@ -1359,13 +1365,14 @@ GetHandleListByPotocol ( **/ EFI_HANDLE* EFIAPI -GetHandleListByPotocolList ( +GetHandleListByProtocolList ( IN CONST EFI_GUID **ProtocolGuids ) { EFI_HANDLE *HandleList; UINTN Size; UINTN TotalSize; + UINTN TempSize; EFI_STATUS Status; CONST EFI_GUID **GuidWalker; EFI_HANDLE *HandleWalker1; @@ -1381,7 +1388,15 @@ GetHandleListByPotocolList ( TotalSize += Size; } } - HandleList = AllocatePool(TotalSize); + + // + // No handles were found... + // + if (TotalSize == sizeof(EFI_HANDLE)) { + return (NULL); + } + + HandleList = AllocateZeroPool(TotalSize); ASSERT(HandleList != NULL); if (HandleList == NULL) { return (NULL); @@ -1389,9 +1404,15 @@ GetHandleListByPotocolList ( Size = 0; for (GuidWalker = ProtocolGuids ; GuidWalker != NULL && *GuidWalker != NULL ; GuidWalker++){ - Size = TotalSize - Size; - Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &Size, HandleList+((TotalSize - Size)/sizeof(EFI_HANDLE))); - ASSERT_EFI_ERROR(Status); + TempSize = TotalSize - Size; + Status = gBS->LocateHandle(ByProtocol, (EFI_GUID*)(*GuidWalker), NULL, &TempSize, HandleList+((TotalSize - Size)/sizeof(EFI_HANDLE))); + + // + // Allow for missing protocols... Only update the 'used' size upon success. + // + if (!EFI_ERROR(Status)) { + Size = TempSize; + } } HandleList[(TotalSize/sizeof(EFI_HANDLE))-1] = NULL; -- cgit v1.2.3