Skip to content

Commit

Permalink
Fix Unitialized variable and Resource leak
Browse files Browse the repository at this point in the history
Tracked-On: OAM-121332
Signed-off-by: Ni, Erchang <[email protected]>
  • Loading branch information
Francesca0901 committed Jul 2, 2024
1 parent fb05ed2 commit bb833b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion gnu-efi-3.0/lib/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ LibCreateProtocolNotifyEvent (
Event,
Registration
);
if ( EFI_ERROR( Status ) ) return NULL ;
if ( EFI_ERROR( Status ) ) {
uefi_call_wrapper(BS->CloseEvent, 1, Event);
return NULL ;
}
ASSERT (!EFI_ERROR(Status));

//
Expand Down
4 changes: 2 additions & 2 deletions gnu-efi-3.0/lib/hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ReadPort (
IN UINTN Port
)
{
UINT32 Data;
UINT32 Data = 0;
EFI_STATUS Status EFI_UNUSED;

Status = uefi_call_wrapper(GlobalIoFncs->Io.Read, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data);
Expand Down Expand Up @@ -105,7 +105,7 @@ ReadPciConfig (
IN UINTN Address
)
{
UINT32 Data;
UINT32 Data = 0;
EFI_STATUS Status EFI_UNUSED;

Status = uefi_call_wrapper(GlobalIoFncs->Pci.Read, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data);
Expand Down
2 changes: 1 addition & 1 deletion gnu-efi-3.0/lib/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ DumpHex (
CHAR8 *Data, Val[50], Str[20], c;
UINTN Size, Index;

UINTN ScreenCount;
UINTN ScreenCount = 0; // Avoid variable being unitialized
UINTN TempColumn;
UINTN ScreenSize;
CHAR16 ReturnStr[1];
Expand Down

0 comments on commit bb833b3

Please sign in to comment.