From 5a16ba3ae18e6528cb83039951e15a4b76004949 Mon Sep 17 00:00:00 2001 From: Jeff Brasen Date: Fri, 16 Nov 2018 16:09:48 +0800 Subject: MdeModulePkg/SdDxe: Fix potential NULL pointer access SdReadWrite can be called with a NULL Token for synchronous operations. Add guard for DEBUG print to only print event pointer with Token is not NULL. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jeff Brasen Reviewed-by: Hao Wu --- MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c index b8d115abac..a4695ffe4d 100644 --- a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c +++ b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c @@ -670,8 +670,9 @@ SdReadWrite ( if (EFI_ERROR (Status)) { return Status; } - DEBUG ((DEBUG_BLKIO, "Sd%a(): Lba 0x%x BlkNo 0x%x Event %p with %r\n", IsRead ? "Read" : "Write", Lba, BlockNum, Token->Event, Status)); - + DEBUG ((DEBUG_BLKIO, "Sd%a(): Lba 0x%x BlkNo 0x%x Event %p with %r\n", + IsRead ? "Read" : "Write", Lba, BlockNum, + (Token != NULL) ? Token->Event : NULL, Status)); Lba += BlockNum; Buffer = (UINT8*)Buffer + BufferSize; Remaining -= BlockNum; -- cgit v1.2.3