From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 CBD32211799DD for ; Thu, 15 Nov 2018 21:33:29 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2018 21:33:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,239,1539673200"; d="scan'208";a="108735573" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga001.jf.intel.com with ESMTP; 15 Nov 2018 21:33:27 -0800 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 15 Nov 2018 21:33:27 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 15 Nov 2018 21:33:27 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.161]) with mapi id 14.03.0415.000; Fri, 16 Nov 2018 13:33:25 +0800 From: "Wu, Hao A" To: Jeff Brasen , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] MdeModulePkg/SdDxe: Fix potential NULL pointer access Thread-Index: AQHUeFAjbCyCBo8KjESYVUTD3iz2U6VR6j2A Date: Fri, 16 Nov 2018 05:33:25 +0000 Message-ID: References: <2e217c22948e3acd3a12c99940d1a3964f648a7c.1541783820.git.jbrasen@nvidia.com> In-Reply-To: <2e217c22948e3acd3a12c99940d1a3964f648a7c.1541783820.git.jbrasen@nvidia.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] 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 05:33:30 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Je= ff > Brasen > Sent: Saturday, November 10, 2018 1:17 AM > To: edk2-devel@lists.01.org > Cc: Jeff Brasen > Subject: [edk2] [PATCH] MdeModulePkg/SdDxe: Fix potential NULL pointer > access >=20 > 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. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jeff Brasen > --- > MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c > b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c > index b8d115a..920e3cd 100644 > --- a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c > +++ b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c > @@ -670,8 +670,11 @@ 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)); > - > + if (Token !=3D NULL) { > + DEBUG ((DEBUG_BLKIO, "Sd%a(): Lba 0x%x BlkNo 0x%x Event %p > with %r\n", IsRead ? "Read" : "Write", Lba, BlockNum, Token->Event, Statu= s)); > + } else { > + DEBUG ((DEBUG_BLKIO, "Sd%a(): Lba 0x%x BlkNo 0x%x with %r\n", > IsRead ? "Read" : "Write", Lba, BlockNum, Status)); > + } How about: DEBUG ((DEBUG_BLKIO, "Sd%a(): Lba 0x%x BlkNo 0x%x Event %p with %r\n", IsRead ? "Read" : "Write", Lba, BlockNum, (Token !=3D NULL) ? Token->Event : NULL, Status)); which is similar to the debug messages in the EMMC counterpart function EmmcReadWrite() in file \MdeModulePkg\Bus\Sd\EmmcDxe\EmmcBlockIo.c. Best Regards, Hao Wu > Lba +=3D BlockNum; > Buffer =3D (UINT8*)Buffer + BufferSize; > Remaining -=3D BlockNum; > -- > 2.7.4 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel