OpenUsbKbDxe: Fixed crashes when handling unsupported keyboards

This commit is contained in:
vit9696 2021-01-23 20:46:11 +03:00
parent c5047889e4
commit 997afa2f4b
4 changed files with 10 additions and 8 deletions

View File

@ -5,11 +5,12 @@ OpenCore Changelog
- Added background image support in OpenCanopy
- Fixed selector boot option choice in OpenCanopy
- Relaxed selector dimensions for OpenCanopy
- Add `MaxBIOSVersion` option to `Generic`
- Fix MLB verification feature in macrecovery
- Added `MaxBIOSVersion` option to `Generic`
- Fixed MLB verification feature in macrecovery
- Replaced `VBoxHfs` driver with `OpenHfsPlus`
- Added audio codec dumping to `SysReport`
- Fix compatibility with page protection for all binaries
- Fixed compatibility with page protection for all binaries
- Fixed crashes in OpenUsbKbDxe when handling unsupported devices
#### v0.6.5
- Fixed installing OpenDuet on protected volumes

View File

@ -24,8 +24,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
ASSERT ((UsbKbDev)->Signature == USB_KB_DEV_SIGNATURE); \
} while (FALSE)
STATIC VOID *mAppleKeyMapDbRegistration = NULL;
STATIC
VOID
UsbKbSetAppleKeyMapDb (
@ -71,18 +69,19 @@ UsbKbAppleKeyMapDbInstallNotify (
ASSERT_USB_KB_DEV_VALID ((USB_KB_DEV *)Context);
ASSERT (((USB_KB_DEV *)Context)->KeyMapInstallNotifyEvent == Event);
UsbKeyboardDevice = (USB_KB_DEV *)Context;
Status = gBS->LocateProtocol (
&gAppleKeyMapDatabaseProtocolGuid,
mAppleKeyMapDbRegistration,
UsbKeyboardDevice->KeyMapInstallRegistration,
(VOID **)&KeyMapDb
);
ASSERT (Status != EFI_NOT_FOUND);
UsbKeyboardDevice = (USB_KB_DEV *)Context;
UsbKbSetAppleKeyMapDb (UsbKeyboardDevice, KeyMapDb);
gBS->CloseEvent (UsbKeyboardDevice->KeyMapInstallNotifyEvent);
UsbKeyboardDevice->KeyMapInstallNotifyEvent = NULL;
UsbKeyboardDevice->KeyMapInstallRegistration = NULL;
}
VOID
@ -115,7 +114,7 @@ UsbKbLocateAppleKeyMapDb (
Status = gBS->RegisterProtocolNotify (
&gAppleKeyMapDatabaseProtocolGuid,
UsbKeyboardDevice->KeyMapInstallNotifyEvent,
&mAppleKeyMapDbRegistration
&UsbKeyboardDevice->KeyMapInstallRegistration
);
ASSERT_EFI_ERROR (Status);
}

View File

@ -482,6 +482,7 @@ ErrorExit:
gBS->CloseEvent (UsbKeyboardDevice->KeyNotifyProcessEvent);
}
ReleaseKeyboardLayoutResources (UsbKeyboardDevice);
UsbKbFreeAppleKeyMapDb (UsbKeyboardDevice);
FreePool (UsbKeyboardDevice);
UsbKeyboardDevice = NULL;
}

View File

@ -156,6 +156,7 @@ typedef struct {
UINTN KeyMapDbIndex;
EFI_EVENT KeyMapInstallNotifyEvent;
VOID *KeyMapInstallRegistration;
EFI_EVENT ExitBootServicesEvent;
} USB_KB_DEV;