From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=216.228.121.64; helo=hqemgate15.nvidia.com; envelope-from=jbrasen@nvidia.com; receiver=edk2-devel@lists.01.org Received: from hqemgate15.nvidia.com (hqemgate15.nvidia.com [216.228.121.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 25E092118D92A for ; Fri, 16 Nov 2018 00:10:09 -0800 (PST) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 16 Nov 2018 00:10:00 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Fri, 16 Nov 2018 00:10:09 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 16 Nov 2018 00:10:09 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 16 Nov 2018 08:10:08 +0000 Received: from HQMAIL103.nvidia.com (172.20.187.11) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 16 Nov 2018 08:10:08 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 16 Nov 2018 08:10:08 +0000 Received: from jbrasen-ux.nvidia.com (Not Verified[10.28.48.113]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7, 5, 8, 10121) id ; Fri, 16 Nov 2018 00:10:08 -0800 From: Jeff Brasen To: CC: Jeff Brasen Date: Fri, 16 Nov 2018 01:09:48 -0700 Message-ID: <554d7bd5193cec18f844e31a9dd598b3c6c7dae2.1542355760.git.jbrasen@nvidia.com> X-Mailer: git-send-email 2.7.4 X-NVConfidentiality: public MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1542355800; bh=r32fioERmnLY9qE3EMNmDjaGtrC7m4Dl+GNOq9iXpcE=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: X-NVConfidentiality:MIME-Version:Content-Type; b=lXIW8oGxY+6uJRXr2csueVGl35xkQhf7iWNf4PLdBOnNbujcLtzi+LKPHO2n1ietk nxk0pU4tKtREkQ+CwWeKNS/5ZUdqzo0PhYuD9Pgl9Fsfb7N+wodVx9NweM0zE4eBcg 337xn6dDnBh8vK27p2Fv+CFGUkLKZNqzHL1wriLJxm5DHMn4zftTD96I/0sg9h2miq SjnS/2aitINAG5vIeBYprl0ZMiqGIzOGsAE7wvKEUHWAUnvHns+pjsm5SWxAbGpY1J YZim4rwQcFX6lzQcQEqJGUHixg8Jq0b/09CNzh0LdxNCLfFavk7Zhek0dcNOwEybJk pzSg51qHJuY7g== Subject: [PATCH v2] MdeModulePkg/SdDxe: Fix potential NULL pointer access X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Nov 2018 08:10:10 -0000 Content-Type: text/plain 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 --- 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 b8d115a..a4695ff 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; -- 2.7.4