From 16a97771adb0678d5e22935a091aebfbfbd3f071 Mon Sep 17 00:00:00 2001 From: eric_tian Date: Mon, 24 Aug 2009 06:24:24 +0000 Subject: [PATCH] free allocated memory in error handler. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9173 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 6 ++++++ MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c index da6ce75b3a..b8a665cff5 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c @@ -394,6 +394,12 @@ ErrorExit: if (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx != NULL) { gBS->CloseEvent (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx); } + if (UsbKeyboardDevice->KeyboardLayoutEvent != NULL) { + gBS->CloseEvent (UsbKeyboardDevice->KeyboardLayoutEvent); + } + if (UsbKeyboardDevice->KeyConvertionTable != NULL) { + FreePool (UsbKeyboardDevice->KeyConvertionTable); + } FreePool (UsbKeyboardDevice); UsbKeyboardDevice = NULL; } diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c index 51ab18223e..40f9a5633a 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -598,6 +598,9 @@ SetKeyboardLayoutEvent ( UINT8 KeyCode; UsbKeyboardDevice = (USB_KB_DEV *) Context; + if (UsbKeyboardDevice->Signature != USB_KB_DEV_SIGNATURE) { + return; + } // // Try to get current keyboard layout from HII database