From: Michael Kubacki Date: Tue, 8 Nov 2022 20:32:41 +0000 (-0500) Subject: PcAtChipsetPkg: Fix conditionally uninitialized variables X-Git-Tag: edk2-stable202305~187 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7dc182ed1e7198420fa10fb523e3d52093fefab2;p=ovmf.git PcAtChipsetPkg: Fix conditionally uninitialized variables Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Erich McMillan Cc: Michael D Kinney Cc: Michael Kubacki Cc: Ray Ni Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Michael D Kinney Reviewed-by: Ray Ni Reviewed-by: Oliver Smith-Denny --- diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index 15759463f2..d8b9fa8376 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -345,7 +345,7 @@ PcRtcInit ( // so we can use them to get and set wakeup time. // Status = PcRtcGetWakeupTime (&Enabled, &Pending, &Time, Global); - if ((Enabled) || (!EFI_ERROR (Status))) { + if ((!EFI_ERROR (Status)) || (Enabled)) { return EFI_SUCCESS; } @@ -838,8 +838,11 @@ PcRtcSetWakeupTime ( // // Just support set alarm time within 24 hours // - PcRtcGetTime (&RtcTime, &Capabilities, Global); - Status = RtcTimeFieldsValid (&RtcTime); + Status = PcRtcGetTime (&RtcTime, &Capabilities, Global); + if (!EFI_ERROR (Status)) { + Status = RtcTimeFieldsValid (&RtcTime); + } + if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; }