From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=203.18.50.4; helo=nat-hk.nvidia.com; envelope-from=jbrasen@nvidia.com; receiver=edk2-devel@lists.01.org Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) (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 52BCE21962301 for ; Thu, 15 Nov 2018 22:11:17 -0800 (PST) Received: from hkpgpgate102.nvidia.com (Not Verified[10.18.92.9]) by nat-hk.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 16 Nov 2018 14:11:19 +0800 Received: from HKMAIL103.nvidia.com ([10.18.16.12]) by hkpgpgate102.nvidia.com (PGP Universal service); Thu, 15 Nov 2018 22:11:15 -0800 X-PGP-Universal: processed; by hkpgpgate102.nvidia.com on Thu, 15 Nov 2018 22:11:15 -0800 Received: from DRBGMAIL103.nvidia.com (10.18.16.22) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 16 Nov 2018 06:11:14 +0000 Received: from HKMAIL103.nvidia.com (10.18.16.12) by DRBGMAIL103.nvidia.com (10.18.16.22) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 16 Nov 2018 06:11:13 +0000 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (216.32.180.113) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Fri, 16 Nov 2018 06:11:13 +0000 Received: from DM5PR12MB2439.namprd12.prod.outlook.com (52.132.141.32) by DM5PR12MB1353.namprd12.prod.outlook.com (10.168.238.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.21; Fri, 16 Nov 2018 06:11:11 +0000 Received: from DM5PR12MB2439.namprd12.prod.outlook.com ([fe80::d0a8:220b:4ebc:35e2]) by DM5PR12MB2439.namprd12.prod.outlook.com ([fe80::d0a8:220b:4ebc:35e2%4]) with mapi id 15.20.1294.045; Fri, 16 Nov 2018 06:11:11 +0000 From: Jeff Brasen To: "Wu, Hao A" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] MdeModulePkg/SdDxe: Fix potential NULL pointer access Thread-Index: AQHUeFAlCYbfmZIOLEe/40/iOk8ddKVR6yqAgAAKQmA= Date: Fri, 16 Nov 2018 06:11:10 +0000 Message-ID: References: <2e217c22948e3acd3a12c99940d1a3964f648a7c.1541783820.git.jbrasen@nvidia.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Enabled=True; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_SiteId=43083d15-7273-40c1-b7db-39efd9ccc17a; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Owner=jbrasen@nvidia.com; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_SetDate=2018-11-16T06:11:09.3049821Z; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Name=Unrestricted; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Application=Microsoft Azure Information Protection; MSIP_Label_6b558183-044c-4105-8d9c-cea02a2a3d86_Extended_MSFT_Method=Automatic; Sensitivity=Unrestricted x-originating-ip: [216.228.112.21] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR12MB1353; 6:ERx3SBnXliABmG7qhTLegvJZCO+hrRk9iqJQxleON3GpSB2QI+nUq3ZUbSwx60Q0kR1Pt4hn3/rosTIpDtRePGJiNLvdxr8LcWTTPlE28jA6m3ScRC6ZKV74z93mNjjbHqsF+tskanqQcTplLjnR1giw+J2CKFsMPAxr6LOGSWVcowJ/oMND/+UYASDZwfFJuRNi9qkB0gQbdiXXsCuScLNYD9rp8mLXCTQWaJOeeyuPNusSBr3hWblFL2bmP788vGvlMZOeqH1y8x1BGZcFYKEHy3STHsYXM9MhFo+Msz7PBRCcXIu5XFLKCaDJZMEEckPeW358AJ64MznCW3lYKFIvbMBNKikzqGxBYn546rP6omUiWCN8F0c8ieQwvETrzP6m4jX25ypa55vw+r4Gc+IhL5JyVn+SH0cYnZ/Bz6ActukdO2x5yNy3X6VGpmy51Di/kqO6XVewkEnKWvG4qw==; 5:jKSCwowxwvHlwKOxkSVM9Tw4qnubBsahJLeWlow0o9UwyKGO0Tb2IA6ICFaraVsIETD0yUSeD/T60b8cTPdWLriVzCPEZ2NdH561kRpJsrHTIWZxsw2FhWT6Dg/Ug/zTUGGM3prr5jC6rgNWMFMefEYrm7TSHVOkz/m6yHPZhLg=; 7:LAtQyx8BL5pxVbav62/xfOpgwUzplHMG9jI9O8WPaPhz8K7LelbmollsXgUnJmc6z6IMfO7jvGvz3URWsNWlVv0Jl9vGXLY85JOwoUZIy8RZZ+TM0oTUOmZkkoSykUpWfm1VqDrIfIOySQvB1YTH7w== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 3a13118f-2614-43c5-ce0d-08d64b8a4e60 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DM5PR12MB1353; x-ms-traffictypediagnostic: DM5PR12MB1353: authentication-results: spf=none (sender IP is ) smtp.mailfrom=jbrasen@nvidia.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(162533806227266)(228905959029699)(18589796830644); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231415)(944501410)(52105112)(3002001)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DM5PR12MB1353; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1353; x-forefront-prvs: 0858FF8026 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(39860400002)(136003)(366004)(396003)(346002)(376002)(189003)(13464003)(199004)(2900100001)(486006)(476003)(229853002)(256004)(3846002)(97736004)(966005)(478600001)(33656002)(14454004)(14444005)(6116002)(5660300001)(11346002)(446003)(186003)(71190400001)(25786009)(71200400001)(8936002)(81166006)(76176011)(86362001)(66066001)(106356001)(105586002)(53936002)(81156014)(110136005)(2906002)(53546011)(316002)(9686003)(6506007)(102836004)(6436002)(7696005)(6246003)(74316002)(68736007)(8676002)(6306002)(55016002)(305945005)(2501003)(7736002)(26005)(99286004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1353; H:DM5PR12MB2439.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Y+Rg3sV/mA4LLXwv2aLH/8Go9CTzroHsWCM0KmTiYA6pkZuYnkc+zfyEKxt+O76vxgO1lKFJD4OkncyrA/qETnehWBYQAQUhA0/Kcb37w4MsFnR9AgwISFiYYd18xXaqwU52k4uOBv0/GMZr7Fz2lUPi8riq2CaWNz9DOFrXovSph22sTB7angaMFqHcljmcYI0vS/xarXV8TSgpwURaSAh7pQrtu1BUYbTEb6dK61sWxmYLhSx/ykgOsrCIY4AoqVMkWUrVFm2iTj53YkbiVpmtuxHXj6dphdZncVKRMlBWSUOoGaX+VPGdUdmRWnWrYNwvXkwsDKlKuJYfjDckU/UpHjfXLNkNmSufxZy1Hsg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 3a13118f-2614-43c5-ce0d-08d64b8a4e60 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Nov 2018 06:11:11.0478 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1353 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1542348679; bh=PxvVgVjsRmPAvJjnXfCfIs+ZsdvSlErO3Lw4408Iqyc=; h=X-PGP-Universal:From:To:Subject:Thread-Topic:Thread-Index:Date: Message-ID:References:In-Reply-To:Accept-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:msip_labels:x-originating-ip: x-ms-publictraffictype:x-microsoft-exchange-diagnostics: x-ms-exchange-antispam-srfa-diagnostics: x-ms-office365-filtering-correlation-id:x-microsoft-antispam: x-ms-traffictypediagnostic:authentication-results: x-microsoft-antispam-prvs:x-exchange-antispam-report-test: x-ms-exchange-senderadcheck:x-exchange-antispam-report-cfa-test: x-forefront-prvs:x-forefront-antispam-report:received-spf: x-microsoft-antispam-message-info:spamdiagnosticoutput: spamdiagnosticmetadata:MIME-Version: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg: Content-Language:Content-Type:Content-Transfer-Encoding; b=iW0v/HZjcU7RDXtI9Wxp47F1OSerMvlspuWw1B50YcMz4lLn+YwEk/U83xV86O/z0 NMom0t3LL+Swl/NpxRMeyPB66RMAWRWmL+1IMqXXsoit5yRrWsl5rKBNEmXA1iK44H 9pla+IKTcRoIXUzRaCXRrYxj09NEKeHB3cIS2GGUhrZU3Ss8YeTa4IuHru/hPX/gx/ HdtR1GbCwFMCVKVCBvV+CYzYe6E29E3f3g/UQP0aLk0nrosBB2hiYmoUNm8pP9Rmnm HcJbyvewLxnbbuq/MqzXqeG2TC88YQuQkI8K0o7HVbpVgYjG+J/nmMgS2g0b+9+u8b gp96pOmGaWvlQ== 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 06:11:19 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sounds good, will upload a v2 patch with that. Thanks, Jeff -----Original Message----- From: Wu, Hao A =20 Sent: Thursday, November 15, 2018 9:33 PM To: Jeff Brasen ; edk2-devel@lists.01.org Subject: RE: [edk2] [PATCH] MdeModulePkg/SdDxe: Fix potential NULL pointe= r access > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of = > Jeff 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=20 > 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,=20 > Status)); > + } else { > + DEBUG ((DEBUG_BLKIO, "Sd%a(): Lba 0x%x BlkNo 0x%x with %r\n", > IsRead ? "Read" : "Write", Lba, BlockNum, Status)); > + } How about: =20 DEBUG ((DEBUG_BLKIO, =20 "Sd%a(): Lba 0x%x BlkNo 0x%x Event %p with %r\n", =20 IsRead ? "Read" : "Write", Lba, BlockNum, =20 (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 -------------------------------------------------------------------------= ---------- This email message is for the sole use of the intended recipient(s) and m= ay contain confidential information. Any unauthorized review, use, disclosure or di= stribution is prohibited. If you are not the intended recipient, please contact the= =20sender by reply email and destroy all copies of the original message. -------------------------------------------------------------------------= ----------