Skip to content

Commit 541034c

Browse files
MarcChen46apop5
authored andcommitted
[Cherry-Pick] NetworkPkg/UefiPxeBcDxe: Add buffer check before reporting status code
When PxeBcLoadBootFile() fails, it reports a status code to notify listeners (such as telemetry/SEL logging drivers) about the error. However, the current implementation reports the status code for all error conditions, including benign cases, such as where the caller passes Buffer == NULL with EFI_BUFFER_TOO_SMALL to query the required size. This causes false positive error reports in telemetry systems, as EFI_BUFFER_TOO_SMALL with Buffer == NULL is an expected and normal operation for size queries, not an actual error condition. The PXE-E05 error message is already correctly guarded with the condition "(Status == EFI_BUFFER_TOO_SMALL) && (Buffer != NULL)", but the status code reporting was unconditional. Add a buffer null check before REPORT_STATUS_CODE_WITH_EXTENDED_DATA to ensure status codes are only reported for actual errors: - Report when Status != EFI_BUFFER_TOO_SMALL (all other errors) - Report when Status == EFI_BUFFER_TOO_SMALL AND Buffer != NULL (PXE-E05) - Skip when Status == EFI_BUFFER_TOO_SMALL AND Buffer == NULL (size query) This prevents spurious error logs while maintaining proper error reporting for genuine failures including PXE-E05, PXE-E07, PXE-E09, PXE-E99, and all other error conditions. Signed-off-by: Marc Chen <[email protected]> (cherry picked from commit d3a64baf4b6706367c30a4886c01e95589861c9f)
1 parent 22a1924 commit 541034c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

NetworkPkg/UefiPxeBcDxe/PxeBcBoot.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,12 +1276,19 @@ PxeBcLoadBootFile (
12761276
AsciiPrint ("\n PXE-E99: Unexpected network error.\n");
12771277
}
12781278

1279-
REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
1280-
EFI_ERROR_CODE,
1281-
(EFI_STATUS_CODE_VALUE)(EFI_IO_BUS_IP_NETWORK | EFI_OEM_SPECIFIC | ((EFI_STATUS_CODE_VALUE)(Status & 0x1F))),
1282-
(VOID *)&(PxeBcMode->UsingIpv6),
1283-
sizeof (PxeBcMode->UsingIpv6)
1284-
);
1279+
//
1280+
// Report status code for all errors printed above.
1281+
// Skip reporting when Buffer is NULL and Status is EFI_BUFFER_TOO_SMALL,
1282+
// as this is an expected size query, not an error.
1283+
//
1284+
if ((Status != EFI_BUFFER_TOO_SMALL) || (Buffer != NULL)) {
1285+
REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
1286+
EFI_ERROR_CODE,
1287+
(EFI_STATUS_CODE_VALUE)(EFI_IO_BUS_IP_NETWORK | EFI_OEM_SPECIFIC | ((EFI_STATUS_CODE_VALUE)(Status & 0x1F))),
1288+
(VOID *)&(PxeBcMode->UsingIpv6),
1289+
sizeof (PxeBcMode->UsingIpv6)
1290+
);
1291+
}
12851292

12861293
return Status;
12871294
}

0 commit comments

Comments
 (0)