diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-23 07:44:49 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-23 07:44:49 +0000 |
commit | d12c6a78aaa2d5bb841733f9c758821875d07dae (patch) | |
tree | bceef1c80c0c00f38793e42a025ab70e935c9e4e /MdeModulePkg | |
parent | 2256f1f7578365c7d8acadb77a1e95373faed78b (diff) | |
download | edk2-d12c6a78aaa2d5bb841733f9c758821875d07dae.zip edk2-d12c6a78aaa2d5bb841733f9c758821875d07dae.tar.gz edk2-d12c6a78aaa2d5bb841733f9c758821875d07dae.tar.bz2 |
error handling enhancement for possible null pointer dereference
Signed-off-by: erictian
Reviewed-by: ydong10
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12437 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c | 21 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 7 |
2 files changed, 18 insertions, 10 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c index 4a5d8e8..b63173d 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c +++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.c @@ -1,7 +1,7 @@ /** @file
The module to produce Usb Bus PPI.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -307,13 +307,13 @@ PeiHubEnumeration ( NewPeiUsbDevice->DeviceSpeed = (UINT8)IsPortLowSpeedDeviceAttached (PortStatus.PortStatus);
if(NewPeiUsbDevice->DeviceSpeed != EFI_USB_SPEED_HIGH) {
- if (PeiUsbDevice->DeviceSpeed == EFI_USB_SPEED_HIGH) {
- NewPeiUsbDevice->Translator.TranslatorPortNumber = (UINT8)Index;
- NewPeiUsbDevice->Translator.TranslatorHubAddress = *CurrentAddress;
- } else {
- CopyMem(&(NewPeiUsbDevice->Translator), &(PeiUsbDevice->Translator), sizeof(EFI_USB2_HC_TRANSACTION_TRANSLATOR));
+ if (PeiUsbDevice->DeviceSpeed == EFI_USB_SPEED_HIGH) {
+ NewPeiUsbDevice->Translator.TranslatorPortNumber = (UINT8)Index;
+ NewPeiUsbDevice->Translator.TranslatorHubAddress = *CurrentAddress;
+ } else {
+ CopyMem(&(NewPeiUsbDevice->Translator), &(PeiUsbDevice->Translator), sizeof(EFI_USB2_HC_TRANSACTION_TRANSLATOR));
}
- }
+ }
//
// Configure that Usb Device
@@ -380,18 +380,21 @@ PeiUsbEnumeration ( CurrentAddress = 0;
- if (Usb2HcPpi != NULL){
+ if (Usb2HcPpi != NULL) {
Usb2HcPpi->GetRootHubPortNumber (
PeiServices,
Usb2HcPpi,
(UINT8 *) &NumOfRootPort
);
- } else {
+ } else if (UsbHcPpi != NULL) {
UsbHcPpi->GetRootHubPortNumber (
PeiServices,
UsbHcPpi,
(UINT8 *) &NumOfRootPort
);
+ } else {
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
}
for (Index = 0; Index < NumOfRootPort; Index++) {
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c index 000430a..fe61219 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -627,13 +627,18 @@ SetKeyboardLayoutEvent ( //
KeyCode = EfiKeyToUsbKeyCodeConvertionTable [(UINT8) (TempKey.Key)];
TableEntry = GetKeyDescriptor (UsbKeyboardDevice, KeyCode);
+ if (TableEntry == NULL) {
+ ReleaseKeyboardLayoutResources (UsbKeyboardDevice);
+ FreePool (KeyboardLayout);
+ return;
+ }
CopyMem (TableEntry, KeyDescriptor, sizeof (EFI_KEY_DESCRIPTOR));
//
// For non-spacing key, create the list with a non-spacing key followed by physical keys.
//
if (TempKey.Modifier == EFI_NS_KEY_MODIFIER) {
- UsbNsKey = AllocatePool (sizeof (USB_NS_KEY));
+ UsbNsKey = AllocateZeroPool (sizeof (USB_NS_KEY));
ASSERT (UsbNsKey != NULL);
//
|