From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.11922.1689560774428689252 for ; Sun, 16 Jul 2023 19:26:15 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=T2tFCk5o; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: hao.a.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689560773; x=1721096773; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=6mDMmHHimuQdOb66czvw4fBX8udwtNLkUIm2+/t2tfM=; b=T2tFCk5oAlYKrMGAjIpzBSoBZ3F6x/lFzuLawFsIpbxafSspU+x0qgEQ KRLU7U+HoE9788CxtdkrqV54/CetCyrs1QN7sgAMRK2X7tKBLZ2aPwNdy HfanxSMQqJkIpPWv8MVYsn/CpD+0M9EGEA10rG4FnMsJs+9rTFbsxdDHU K02wq6cumFy3+3XoIwyOCBtKvTPdVdhXx9HY7TKyYpdXBOU8iQvd0u1YK K9gKAejlo93pWNjqoTLd7XCw6RIP7dkNKy92layWXindvH1noyGpMtpHR BsKPlvSWyFv3E56JIDMODZAKEY7z/AeyfclDquUsKbLLG4xfMHf4ekt7j w==; X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="396649738" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="396649738" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2023 19:25:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10773"; a="969691259" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="969691259" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga006.fm.intel.com with ESMTP; 16 Jul 2023 19:25:57 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sun, 16 Jul 2023 19:25:57 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sun, 16 Jul 2023 19:25:57 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Sun, 16 Jul 2023 19:25:56 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.172) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Sun, 16 Jul 2023 19:25:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GG+C/c+ykA6XyvHlhhwIEKlm5BkgsQSxd/ef72KT9r1cgvprt0Pyd/eXpn04CIkH12FebVju92FQaghDg+WPcJZvxkdvw2J9B7i9yYV6UnIOqw+r2E9QQeHKqw78jUHuiPRvj+Impzk3UhCHDDBqVUHYELJm5T2itybsdVxkI8TbzWfRf90X4xaCRaZiNr341ChyP7XcvV9xTCR01c043uzDudTo0swQwxMe/5rXIzQRKtg3eXtrqKlCw8ZHG1uGEP2FBtqI+uSAwlj/1g24+hso91FUNP28lZ7kYWsuorpbv0NeldysZC7X0dQr+/zONjWuJ6NcokNTxWctumBVYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rK8G4eHBmEQWwmJVEvTeaR72Dk+ynl09BqiWyd+BOa4=; b=oe3JaGIiwwZLS+WRw05BGrUAlpVY03ryNZb+oisVeWcKkr6R1511VF7S11wuxbeXphWBhcK0fRFXIglar+KaSKjVgD3gtFDmCWmS2ATCfHj5NvWhtEL81nXOrUdiYeab1XEKLYXiLqyqCAaqGtLk0g2+3LAuyR1hKrGwenbETbGPimDC6h+eUtk0doOEJZ0kMetASL4W4GsUUiMmd2+km9mn6CYqxShGJ6y6OuikQagCWvo6dsQ8sDUWP3y9D0DXIzmiQ+nmCjXaUWdf/KKJIkJ7XEH5KqPGAD1nwZP4xHC4ei6npCm+4ytGaRLispr8Uy0HsTOX2VST0yodckEOLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MN2PR11MB4031.namprd11.prod.outlook.com (2603:10b6:208:150::18) by PH8PR11MB7069.namprd11.prod.outlook.com (2603:10b6:510:217::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Mon, 17 Jul 2023 02:25:54 +0000 Received: from MN2PR11MB4031.namprd11.prod.outlook.com ([fe80::e80c:88f:c18e:52c3]) by MN2PR11MB4031.namprd11.prod.outlook.com ([fe80::e80c:88f:c18e:52c3%5]) with mapi id 15.20.6588.031; Mon, 17 Jul 2023 02:25:54 +0000 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "Wu, Hao A" , Ranbir Singh CC: "Ni, Ray" Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/Bus/Pci/EhciDxe: Fix FORWARD_NULL Coverity issues Thread-Topic: [edk2-devel] [PATCH 1/1] MdeModulePkg/Bus/Pci/EhciDxe: Fix FORWARD_NULL Coverity issues Thread-Index: AQHZraPEsIKQNTz6+UOPA4FxaM0KpK+1nO6ggAezqpA= Date: Mon, 17 Jul 2023 02:25:53 +0000 Message-ID: References: <20230703114424.227779-1-rsingh@ventanamicro.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR11MB4031:EE_|PH8PR11MB7069:EE_ x-ms-office365-filtering-correlation-id: 3154e326-1c8a-4b21-35c7-08db866d2526 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: mEIcudILgQ6s/rbFsz9SH2aklu4qS7YHDWPBWDyx+IsXkDXXWCY/Nc1Kiq6N0Q/E/TNY8za4n14mmmNe+ffHxhorBMR7G4jOP3AVKNKmfKYuOd3/C5sP/bHTB5ysGG8x11NRbCJwv8ESjWXu17xJOMsWgyWPOSvq1BSILf5DTkS4JNSonskdNCJXiOawY/rRSDdoYDRP2vh+Zzz/tQZ9ulgPcIVU3q7BdZ/7Kt8JTTGh0/FE2OdOVJkTaCbjAAWFL/mS4VsQj1CEJ0AU9D8aOaCIehF4ajVMzqBJx6XbUnTKdojlgk4/oP/zoi/Xf0IyRbxEEwCtEF4Gcwo1VrdCIePH6JVs5D47rH9V2V+EEBip2umuDKH6BUbLQmtv0WYxLlACSCHbgmn8F/lalfj6oIjYxQIPzEY0sNswMqPgxDTpnrPDb2DgTKydRRmSObvUkyz8axEpOPBS90w8UTZcKsuKOMKOLzM+HmEG2Tz5l9frD18SBq4ayFySAfC2g8zdYNzcibNKJfx18cLj5i7TaS4HJ9XFS3Py/h3rcdXBI4Az0LzhqeN9cT5CdQhb2SsdUwZK6GXa7QgntOM3KhfHFfIoHm6R6+ff+oUCprRz/eUBxhd1ZGlsuTpbG+KyToMWFhd9qsz7yAUbabMWqmquPw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR11MB4031.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(136003)(346002)(366004)(376002)(396003)(451199021)(41300700001)(83380400001)(2906002)(4326008)(107886003)(8676002)(55016003)(66556008)(66446008)(66476007)(76116006)(38100700002)(316002)(6506007)(53546011)(8936002)(52536014)(966005)(64756008)(26005)(33656002)(82960400001)(478600001)(9686003)(66946007)(38070700005)(86362001)(110136005)(71200400001)(7696005)(5660300002)(186003)(122000001)(66899021);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?hxAKvS8+JfCUZjhYbtB4q+gFSf2wBeN909rUK17JNv7TOBQBoYHiETEz/ZWC?= =?us-ascii?Q?Vo8Ij3lZceiAbJQ4NLylBriUftTllTGY12DyI9QfZXhXGa3zYV0aoRq918wm?= =?us-ascii?Q?1LZVs9BF0A2ur/mSZBdn3TaUBswxp+Kr8Tunaj1JNLG+Q9Eat73UotGlbru0?= =?us-ascii?Q?Jn/zECoviJLPBlFGylvCEoIb0dBkSf3UL/ZcYXVLu4CBXjTCZOblD1tJqz3m?= =?us-ascii?Q?y5Us3B1WQf4IyVDKPQJ6W0+6rl1V7xFfCteYC/JBfQwn6A6Y+VvTFQJUfho8?= =?us-ascii?Q?yM8QhJTwQOHeR4SgdHN5VC+B+CvLA8FjKwsIfrlcNcq3qmfbJUBzwewZ9Blr?= =?us-ascii?Q?QMrgJKoB9Fr4IS4a/b0ZMakJKhAczndk/HX0JrM+68Bs5gjl4uDV5Czl8SDm?= =?us-ascii?Q?GGhSvu09AZQnzxjWvpAt0gpvIzDYcakU1NYedHzj48KS6nrNkXDlMfOoAn+j?= =?us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qWqtV/b3wytQtr28?= =?us-ascii?Q?foPO6kVi04U5JANAvG6EEK8GROP0/61fvyP6jJe7NbA3HAEY6vluv+EimMDa?= =?us-ascii?Q?oi8kaLIrCo33lmtlYjeBVREHQ7qIiYiKEmtBxkAPSzlRR309s9eR5i5KS9pb?= =?us-ascii?Q?S/L4f8HN2exDqqi/E0QuyyyUS3jSawTTsDOssaH9CfUGL8qF9xUj8cV7Anhg?= =?us-ascii?Q?SSYZveBvjV5JohGXzZabZ4cS4rorhp3Fz6VoLGVm?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR11MB4031.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3154e326-1c8a-4b21-35c7-08db866d2526 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2023 02:25:53.5655 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rl/mWzVKrXrdLGqiDKtH7UI1jjo4Ywz263ESv5HvvxNq8iopAjQ105u7WcymHQcissDruD6JyeoAvjY4X3VbSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB7069 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Merged via: PR - https://github.com/tianocore/edk2/pull/4648 Commit - https://github.com/tianocore/edk2/commit/dd49d448b0815c65847241a3f= aa957e3b4605001 Best Regards, Hao Wu > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wu, Hao A > Sent: Wednesday, July 12, 2023 12:49 PM > To: Ranbir Singh ; devel@edk2.groups.io > Cc: Ni, Ray > Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg/Bus/Pci/EhciDxe: Fix > FORWARD_NULL Coverity issues >=20 > Reviewed-by: Hao A Wu >=20 > Best Regards, > Hao Wu >=20 > > -----Original Message----- > > From: Ranbir Singh > > Sent: Monday, July 3, 2023 7:44 PM > > To: devel@edk2.groups.io; rsingh@ventanamicro.com > > Cc: Wu, Hao A ; Ni, Ray > > Subject: [PATCH 1/1] MdeModulePkg/Bus/Pci/EhciDxe: Fix FORWARD_NULL > > Coverity issues > > > > From: Ranbir Singh > > > > The function UsbHcGetPciAddressForHostMem has > > > > ASSERT ((Block !=3D NULL)); > > > > and the UsbHcFreeMem has > > > > ASSERT (Block !=3D NULL); > > > > statement after for loop, but these are applicable only in DEBUG mode. > > In RELEASE mode, if for whatever reasons there is no match inside the > > for loop and the loop exits because of Block !=3D NULL; condition, then > > there is no "Block" NULL pointer check afterwards and the code > > proceeds to do dereferencing "Block" which will lead to CRASH. > > > > Hence, for safety add NULL pointer checks always. > > > > Cc: Hao A Wu > > Cc: Ray Ni > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4210 > > Signed-off-by: Ranbir Singh > > Signed-off-by: Ranbir Singh > > --- > > MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c > > b/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c > > index 0a3ceb9f711a..79575b6f6304 100644 > > --- a/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c > > +++ b/MdeModulePkg/Bus/Pci/EhciDxe/UsbHcMem.c > > @@ -250,6 +250,11 @@ UsbHcGetPciAddressForHostMem ( > > } > > > > > > > > ASSERT ((Block !=3D NULL)); > > > > + > > > > + if (Block =3D=3D NULL) { > > > > + return 0; > > > > + } > > > > + > > > > // > > > > // calculate the pci memory address for host memory address. > > > > // > > > > @@ -536,6 +541,10 @@ UsbHcFreeMem ( > > // > > > > ASSERT (Block !=3D NULL); > > > > > > > > + if (Block =3D=3D NULL) { > > > > + return; > > > > + } > > > > + > > > > // > > > > // Release the current memory block if it is empty and not the head > > > > // > > > > -- > > 2.34.1 >=20 >=20 >=20 >=20 >=20