diff options
author | Feng Tian <feng.tian@intel.com> | 2016-04-01 16:37:53 +0800 |
---|---|---|
committer | Feng Tian <feng.tian@intel.com> | 2016-04-21 15:53:09 +0800 |
commit | 18b50d66d3fc2bd03ebb698f5bfb1a1743dfbe91 (patch) | |
tree | 1ad09dcc2f6e02bdc83d2252c3473848f383bed7 /MdeModulePkg | |
parent | b5e44fbc15085270adfc777c0f2c1890c1e9790f (diff) | |
download | edk2-platforms-18b50d66d3fc2bd03ebb698f5bfb1a1743dfbe91.tar.xz |
MdeModulePkg/UsbKbDxe: don't assert when the key read is invalid
The GetKeyDescriptor() may return NULL when the KeyData is invalid.
For such case, we should go to error handling path rather than assert
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c index 86dd99d254..fef1449e3c 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -1,7 +1,7 @@ /** @file
Helper functions for USB Keyboard Driver.
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
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
@@ -1195,7 +1195,9 @@ KeyboardHandler ( // Handle repeat key
//
KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, CurKeyCodeBuffer[Index]);
- ASSERT (KeyDescriptor != NULL);
+ if (KeyDescriptor == NULL) {
+ continue;
+ }
if (KeyDescriptor->Modifier == EFI_NUM_LOCK_MODIFIER || KeyDescriptor->Modifier == EFI_CAPS_LOCK_MODIFIER) {
//
@@ -1272,8 +1274,9 @@ USBParseKey ( Dequeue (&UsbKeyboardDevice->UsbKeyQueue, &UsbKey, sizeof (UsbKey));
KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, UsbKey.KeyCode);
- ASSERT (KeyDescriptor != NULL);
-
+ if (KeyDescriptor == NULL) {
+ continue;
+ }
if (!UsbKey.Down) {
//
// Key is released.
@@ -1513,7 +1516,9 @@ UsbKeyCodeToEfiInputKey ( // KeyCode must in the range of [0x4, 0x65] or [0xe0, 0xe7].
//
KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, KeyCode);
- ASSERT (KeyDescriptor != NULL);
+ if (KeyDescriptor == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
if (KeyDescriptor->Modifier == EFI_NS_KEY_MODIFIER) {
//
|