Skip to content

Commit

Permalink
HidPkg: More CodeQL fixes (#204)
Browse files Browse the repository at this point in the history
## Description

Various fixes

- [x] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [x] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

## How This Was Tested

Build and boot changes on QemuQ35Pkg to EFI shell.

## Integration Instructions

N/A
  • Loading branch information
TaylorBeebe authored and kenlautner committed May 14, 2023
1 parent bdc4a95 commit 083f363
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions HidPkg/HidKeyboardDxe/HidKeyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,14 @@ SetKeyboardLayoutEvent (
//
ReleaseKeyboardLayoutResources (HidKeyboardDevice);
HidKeyboardDevice->KeyConvertionTable = AllocateZeroPool ((NUMBER_OF_VALID_HID_KEYCODE)*sizeof (EFI_KEY_DESCRIPTOR));
ASSERT (HidKeyboardDevice->KeyConvertionTable != NULL);
// MU_CHANGE [BEGIN] - CodeQL change
if (HidKeyboardDevice->KeyConvertionTable == NULL) {
ASSERT (HidKeyboardDevice->KeyConvertionTable != NULL);
FreePool (KeyboardLayout);
return;
}

// MU_CHANGE [END] - CodeQL change

//
// Traverse the list of key descriptors following the header of EFI_HII_KEYBOARD_LAYOUT
Expand Down Expand Up @@ -610,7 +617,15 @@ SetKeyboardLayoutEvent (
//
if (TempKey.Modifier == EFI_NS_KEY_MODIFIER) {
HidNsKey = AllocateZeroPool (sizeof (HID_NS_KEY));
ASSERT (HidNsKey != NULL);
// MU_CHANGE [BEGIN] - CodeQL change
if (HidNsKey == NULL) {
ASSERT (HidNsKey != NULL);
ReleaseKeyboardLayoutResources (HidKeyboardDevice);
FreePool (KeyboardLayout);
return;
}

// MU_CHANGE [END] - CodeQL change

//
// Search for sequential children physical key definitions
Expand Down
1 change: 1 addition & 0 deletions HidPkg/HidPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

HiiLib |MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
UefiHiiServicesLib |MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
SafeIntLib |MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf # MU_CHANGE - CodeQL change

[LibraryClasses.X64]
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
Expand Down

0 comments on commit 083f363

Please sign in to comment.