From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7A5E8740032 for ; Thu, 10 Aug 2023 02:39:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Yn9F8Ph6JnZ8NaFXwWTy30w+iSTORtLvLHYi5imI/W0=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1691635145; v=1; b=sZ6zbexdapmVCWp0lt2+hayPC8OioeJxbCSkVhr0gA1uEJySKauG2W6TLBSE/64lCxBzPMvn g8wRdoo9wlqIuumK6vsef1jQMHlNcuU5lpOta9SqFbNcbYQyn/BWQo2fZm16NTa1lDpblg+OHTF 18pvK3ZTCOD6CtZB4q/6k7tg= X-Received: by 127.0.0.2 with SMTP id lFgHYY7687511xGfgqzy4nib; Wed, 09 Aug 2023 19:39:05 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.9130.1691635142323838983 for ; Wed, 09 Aug 2023 19:39:02 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10797"; a="437638043" X-IronPort-AV: E=Sophos;i="6.01,160,1684825200"; d="scan'208";a="437638043" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2023 19:38:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10797"; a="846194411" X-IronPort-AV: E=Sophos;i="6.01,160,1684825200"; d="scan'208";a="846194411" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga002.fm.intel.com with ESMTP; 09 Aug 2023 19:38:55 -0700 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 9 Aug 2023 19:38:55 -0700 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Wed, 9 Aug 2023 19:38:55 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Wed, 9 Aug 2023 19:38:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GtS4MiKqaJ0vNd1tHz/MGwIUNkhhEtR79dYkXFSXxbyn6nvdpklpN1EyZjBjkF99HaQSW49Rh2B37RlCRrtceplPqppDmpRCsaa4vIUuXvcb9E41Xn3ZQ/3Rlo62Pg9AvCBi919AOvMoaLIzoNh4OmE9z1X5XLECxCV4eOO4WHcIcoCoGRNtxiOiArTr3RcXSaeAjYD+YBRf8cBLjWVXV6G7yt+vLYBw3lG4jpNp/zAmQXCozx02w+GGO8htyjKxtzx0iKRyYOO64GnJRs49hrJsivpZl6J2UmiX53Q0gVnn4mhV7275RWgP1PfoyhaWWJ14kAI3t070kzIlEDrSng== 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=bXyv6ZPZo2oMX1MSBDznH/T85zpHPYCyqaGt9d2fRT4=; b=JWfUC8h32MKUgLKYYu/ucDEE9lB8+yiXh1uj3OPScl0IZF5Ilol+nbJ2inKiLrLPbD1yxlInmnAEmHqhjkU6zWGtFP8wJ2yKD3jgeIedgftUdgX6kpGKdk8460z6EwkZGw05gh1z9in6l5mvpZAlnzlfIY6c2RGkVWSyyFo1i6ecax9Uv8JFy/hNHVCo2Antzft2dlKX1Lcr8xQGLrweFAM7BhPqARMXsEbQUYHxOoZ/BZGHxoQNLW+Ad/oZGGnWn7Etng6zzA4QpTfHa+gCIjzZRsQyj9CYhC3OGAvdItuh2WR8vj2ztAq8/j1t1+wDHPAUbk6CPzn7yFsiMgUBig== 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 X-Received: from DM6PR11MB4025.namprd11.prod.outlook.com (2603:10b6:5:197::31) by LV8PR11MB8584.namprd11.prod.outlook.com (2603:10b6:408:1f0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Thu, 10 Aug 2023 02:38:51 +0000 X-Received: from DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::ebe2:341b:4ed7:d19b]) by DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::ebe2:341b:4ed7:d19b%6]) with mapi id 15.20.6652.029; Thu, 10 Aug 2023 02:38:51 +0000 From: "Wu, Hao A" To: Ranbir Singh , "devel@edk2.groups.io" CC: "Ni, Ray" , Veeresh Sangolli Subject: Re: [edk2-devel] [PATCH v1 2/2] MdeModulePkg/Bus/Pci/UhciDxe: Fix FORWARD_NULL Coverity issues Thread-Topic: [PATCH v1 2/2] MdeModulePkg/Bus/Pci/UhciDxe: Fix FORWARD_NULL Coverity issues Thread-Index: AQHZuKNAfXWzfFg9/UylUlnjm7eaIK/i7Fmg Date: Thu, 10 Aug 2023 02:38:51 +0000 Message-ID: References: <20230717113831.2290882-1-rsingh@ventanamicro.com> <20230717113831.2290882-3-rsingh@ventanamicro.com> In-Reply-To: <20230717113831.2290882-3-rsingh@ventanamicro.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR11MB4025:EE_|LV8PR11MB8584:EE_ x-ms-office365-filtering-correlation-id: 0a63c6dc-0fd4-4c84-a7ed-08db994aeee8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: aitdOFDn+OzI3DXPb39/q06IeAXWyn9sVOZV/7NqwQxfzRJvrSYY7gAe5uvXFRBOrGnQmRyNHMKrDPGRHLwv5PnR/YD1IDPrZtdaosLBjNAWUS88SdiVtbMhl3tO4aJtkKrd7JLtzka/jaO9PRJXm2dWnbSFfmrkvAGWjswmaoD/5ad+oCFxyzVv35lCIL2fIpdTpPcTH+r30PlkCC48C/yQasl67Gaue3PwKLA2Xp5W2DSENbJ3bEiiEvFMAKYrVry85ta5ucUK/89f+EhFduL1UoJmArKKUUmr+H99/7IrWOi1e0KD6JMg60EQoKRqLPYTj+v70RK3vWwGHnFYMOr8hbUyxO0c6UbAp1eUvh8Ty9RyEUYkNvfmhoaobnBwTfx1c1aSpT/1kTFG7l0L6zitx7+iYnxSz7solxr+NZXHY4eqb1lcfyBJQaN6gEKZyJzBRWjKY9Mn195Mq/J7h6+c1tSjssjcsi/UDyRqSfBpQigj/XrfbJudtZgkHkHjFDUKDAP1odcFOP4kdx2Tvkd/LT3ndNpESTIFE/sOvsxy0qCCFhw09Hy9l8ag86CtydNPeW2PA4b3tXoqBxHd4xLDr360EDg+zvgW6tPd24o= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Q3gm6bKw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ult2Tz5?= =?us-ascii?Q?OwvyY5jX1MSRFe85f802x02radrTwsHlzpOx4Z1AS3Ko2m57ZYNHbWxYSI/j?= =?us-ascii?Q?g1Lw924ZjcCuAkCt9ksihbzjJ1/nD69iG+vGv6B9uIbM9eubYBoqys16ddWf?= =?us-ascii?Q?50OX0Qrp1dcdFB4TRWUGD78TQJr+SK27i1liP1iQg9yZwRde/+JxDGX4r63u?= =?us-ascii?Q?8/Hm5yP9SWXGZCfAVEc4ArxxH47TUs5EOG+nZNqfnygx4fY1T+bxF2yGNErj?= =?us-ascii?Q?BPI8FSB5ciGLIifPURC2tsdhexQl1i7lVAaV4yUal1sbLViXN9dV3Zm4UtxZ?= =?us-ascii?Q?ZINkhDo4Ea6F6ZDzFIcE/AdC8PLvpnmfvMp4ZS7qsekDURa1OrI2ldZQ9Pgr?= =?us-ascii?Q?QVQKTCZsfVJIXA5dnFrjKMLBdHrKSvXy28c09ghEGkaj0899yUEUGwg9rZQV?= =?us-ascii?Q?MUqLOKgNRVDVO6e6A5UOqmWjwivWWzRHRRukE+ffDSXunDT2AKYYQdHt5Hkm?= =?us-ascii?Q?oJXQvnZrEgOMyN09asnwVsQY/Hj0Sk7lIXLD0E+BFnPexKQv0CGRw48jTOLR?= =?us-ascii?Q?8R9jJr0G1TpPQXsmREkf0ilGmQnmkokl8iQh37X7vfGfR0vidhWNperIaRA3?= =?us-ascii?Q?ije+ekLCoCFrVVCwh1fGueUzev5JZCHf/cVWJFWY/1wgR/Lc6XdD+Bl0NB20?= =?us-ascii?Q?jesoiXbUpD92vWJh1Eh0bV1GUroIJuS9vzaFEUKp?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4025.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a63c6dc-0fd4-4c84-a7ed-08db994aeee8 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Aug 2023 02:38:51.7780 (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: w3aqaVH8JzO3dB/C5ofhKDhvdEsucFjTPG7vsiE3wY+AkdsbIeRY7n53KywtZl6Gey6ZV/ViR2Bv7x534NhSFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR11MB8584 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,hao.a.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: MQLtUgpOxGNrRz0mPvE9o48Ox7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=sZ6zbexd; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Reviewed-by: Hao A Wu Best Regards, Hao Wu > -----Original Message----- > From: Ranbir Singh > Sent: Monday, July 17, 2023 7:39 PM > To: devel@edk2.groups.io; rsingh@ventanamicro.com > Cc: Wu, Hao A ; Ni, Ray ; Veeresh > Sangolli > Subject: [PATCH v1 2/2] MdeModulePkg/Bus/Pci/UhciDxe: Fix > FORWARD_NULL Coverity issues >=20 > From: Ranbir Singh >=20 > The function UsbHcGetPciAddressForHostMem has >=20 > ASSERT ((Block !=3D NULL)); and >=20 > and the function UsbHcFreeMem has >=20 > ASSERT (Block !=3D NULL); >=20 > statement after for loop, but these are applicable only in DEBUG mode. > In RELEASE mode, if for whatever reasons there is no match inside 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. >=20 > Hence, for safety add NULL pointer checks always. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4211 >=20 > Cc: Hao A Wu > Cc: Ray Ni > Co-authored-by: Veeresh Sangolli > Signed-off-by: Ranbir Singh > Signed-off-by: Ranbir Singh > --- > MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c | 9 +++++++++ > 1 file changed, 9 insertions(+) >=20 > diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c > b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c > index c3d46f60bed5..3794f888e132 100644 > --- a/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c > +++ b/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c > @@ -250,6 +250,11 @@ UsbHcGetPciAddressForHostMem ( > } >=20 >=20 >=20 > ASSERT ((Block !=3D NULL)); >=20 > + >=20 > + if (Block =3D=3D NULL) { >=20 > + return 0; >=20 > + } >=20 > + >=20 > // >=20 > // calculate the pci memory address for host memory address. >=20 > // >=20 > @@ -536,6 +541,10 @@ UsbHcFreeMem ( > // >=20 > ASSERT (Block !=3D NULL); >=20 >=20 >=20 > + if (Block =3D=3D NULL) { >=20 > + return; >=20 > + } >=20 > + >=20 > // >=20 > // Release the current memory block if it is empty and not the head >=20 > // >=20 > -- > 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107680): https://edk2.groups.io/g/devel/message/107680 Mute This Topic: https://groups.io/mt/100212110/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-