From bb833b3d213177532529e01786871dedc34fecd4 Mon Sep 17 00:00:00 2001 From: "Ni, Erchang" Date: Tue, 2 Jul 2024 07:17:53 +0000 Subject: [PATCH] Fix Unitialized variable and Resource leak Tracked-On: OAM-121332 Signed-off-by: Ni, Erchang --- gnu-efi-3.0/lib/event.c | 5 ++++- gnu-efi-3.0/lib/hw.c | 4 ++-- gnu-efi-3.0/lib/print.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gnu-efi-3.0/lib/event.c b/gnu-efi-3.0/lib/event.c index 0babc92..faebf03 100644 --- a/gnu-efi-3.0/lib/event.c +++ b/gnu-efi-3.0/lib/event.c @@ -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)); // diff --git a/gnu-efi-3.0/lib/hw.c b/gnu-efi-3.0/lib/hw.c index 09a77f9..bbefdc5 100644 --- a/gnu-efi-3.0/lib/hw.c +++ b/gnu-efi-3.0/lib/hw.c @@ -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); @@ -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); diff --git a/gnu-efi-3.0/lib/print.c b/gnu-efi-3.0/lib/print.c index 35e43c0..9e79d97 100644 --- a/gnu-efi-3.0/lib/print.c +++ b/gnu-efi-3.0/lib/print.c @@ -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];