From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.26899.1661222730829223572 for ; Mon, 22 Aug 2022 19:45:30 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Y63oWBvn; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: james.lu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661222730; x=1692758730; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=U+PBASveFN9Bxww4k/Hml6uiRj+DEKCDGPPe8LZg6BQ=; b=Y63oWBvn2ilu80bGVZHfOqj8XEpjW6GYX4aAi3cckWBnDvope+Y/WbwS 6La5JJd9p6RJlfjNSI3cc1ufrNwg+rVhhBQRFWBOXVkF9Lp1N+zeO5yED lExBvhnHs2/3thL9jXWisV7Jcu6f0g2dualeUrQ3/f7hCiHWtM4uX0bTK CGr4/9oSkt+NMK+RSIYUrrPPsHBYdhLZPzp0RSY5cZC+5H+DmLCL3vTsJ dLDI8y3SdNCzZmYkFnGgaupDcF+ev3EUsPvenfs1KenzWHlSigf/jrsYw KAXnu9kk547MjVQldP3CdkmdVAm+GdLhAmN+wutfZ4RjLA1XZ3jO62AJ5 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10447"; a="293571889" X-IronPort-AV: E=Sophos;i="5.93,256,1654585200"; d="scan'208";a="293571889" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2022 19:45:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,256,1654585200"; d="scan'208";a="605508950" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga007.jf.intel.com with ESMTP; 22 Aug 2022 19:45:21 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 22 Aug 2022 19:45:20 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 22 Aug 2022 19:45:20 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Mon, 22 Aug 2022 19:45:20 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.42) 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.2375.31; Mon, 22 Aug 2022 19:45:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WPnavxIxlDhH7GTJp9GQQf8gYYB4zzXenwckehyhZXbXXIRwbxEtM4qSXxmo0+8Bnv8lmiRbdfLV2lPut/KYMH+1XGt3AnqEiDCb8XxSFSAbQOn3ZJ2JJZ37BU5zM2v4ZHvuzqokeiGWUjE1J4st/0G8MqWaFypKi+vNCG1Lj0uzKIb5XlUmk1dAaWeHLsBuSyhxlSLOPpi4FtY9CwW+5F9ZJimrAKW7zDnaCJUKTpukNaiLeykyPgs//noX/k7BCqnLlLwp0u78xi5MPIstTN0Re5ayuGDe0nhFwhnPwIDWPZuTpUGq1b5NKVEsDbrl5XGgpOkGn0x4zsnwjIQ+Qw== 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=CPluV3vJR1aXqphQ/vNinVdwfCLcMBs4rPwsZdXq2hU=; b=BX53SoKxPqYawxPHssfGNHXAN+6TKBmi+yWzLfPoR9k8MVJ8q3jO9oQ8B2dd5pRiLsqdFWjTqdbVtWHpkJqevwmexu8DhqopOyYiwCv4UCApCA878wjIZa0eCTDhq5GCUYyiOPqJHRh7kl0Ed2Q4vptnVvDRQBstHHSGQ33bw37PGi/GX1qfiFrX4Xsl//9x/4l012POP8S1UjTy5kVSZIon4dpSIvvjeWaz6BgPbmk541ruY8MKB8nWEsaDBZqNPBsljpu2xh49vm7tuY0YfiW7+pZ1XGQ+xlqIZA9AmUk8j+0qMmdg6GpkvrDmAw8bQY7axNsn9tq3OKKxAK9EGQ== 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 BN6PR11MB1908.namprd11.prod.outlook.com (2603:10b6:404:103::13) by DM6PR11MB2587.namprd11.prod.outlook.com (2603:10b6:5:c3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Tue, 23 Aug 2022 02:45:17 +0000 Received: from BN6PR11MB1908.namprd11.prod.outlook.com ([fe80::9c39:88cf:f55:b7a]) by BN6PR11MB1908.namprd11.prod.outlook.com ([fe80::9c39:88cf:f55:b7a%10]) with mapi id 15.20.5546.022; Tue, 23 Aug 2022 02:45:17 +0000 From: "Lu, James" To: "devel@edk2.groups.io" , "Yeh, GregX" , "Guo, Gua" Subject: Re: [edk2-devel] [PATCH] UefiPayloadPkg: Fix Coverity report defect Thread-Topic: [edk2-devel] [PATCH] UefiPayloadPkg: Fix Coverity report defect Thread-Index: AQHYrUvAkTc4yLlEHku7QlF1WG0z/6272gdQ Date: Tue, 23 Aug 2022 02:45:17 +0000 Message-ID: References: <20220811062922.2981-1-gregx.yeh@intel.com> In-Reply-To: <20220811062922.2981-1-gregx.yeh@intel.com> Accept-Language: en-001, en-US, zh-TW 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-office365-filtering-correlation-id: dfb74f58-ac53-4312-c203-08da84b1835e x-ms-traffictypediagnostic: DM6PR11MB2587:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Z5DULeNVOKKqED77YFZ1GalZoTZWFUpcfh/E1U8LiArXzwMQonZ+UTuNW7gLhs8g7Bcv1L3OalqL2Ld0MU/0zXVynuvd5XVjjPpX7vlLK303O4R9/waS7R9/dJMvGJI2sRaQeaslH8nQPwAXlEhFKVZqQxI5fCZCgslNlvVbK7cnxnZxuL5Ez1FJtZT7S1jG6YIYmxSp119X+gPvDCId1Qmo7bcyWCGw+WmS7O00PyPc22BVIb7n9QAT1/nbP6YTpNOrZondOi+DW6HBkH1OPc+2+xNo1Nl1euSWABoLJVMSa8rZpPcQVllBRjcujZPsgq2AXw3YBZ5tQHP1aXeCQ6X0prUd3tJHmqwUog70E97oS/h+nJb6Epm37iGpGmFgRZM4ByLXHFhxE4/8c0czzhj3coOQzgcPNin+Ign4DBCV+D9BipagXeiUoB04rmjx/xQ4DRem0K9pmYcyohffemPYNfLOfZ9qjjz/ih82qmmkN/U6pnD73ZuBoAJVHveHromAq23me67h8gO4XEiBbquoRWkMsIEeXZnfHiWZ3y0r5VCwgSnmA+ebVqPpV4xnDaPRffuvdbDgUorA8T0Y+1XTkTjXT4//TKPpiQIL/DHXMYE3fJ0E99H/0m0j0aVZOYLLgiWFATWBSHFpuWiaKlnDNM+P1C9VjlyGzBOSquLtX+gTcHH2ekpUPVuSsBAZbGI9NcL7vxx46AAhSGN5ENi4da52m8pxjRSB4UvVvvlbL8mE6P+/7ph4gWJrf9wSsB4TurTHJ7CES7jkUkR5Ib5VLSuWMBZk9G8QA9z7B4U4xl31ZW9q5U4l+C7yzi+T1UuSJFw9poI1uEX8+c9flQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR11MB1908.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(366004)(396003)(39860400002)(346002)(376002)(9686003)(7696005)(6506007)(53546011)(26005)(478600001)(41300700001)(71200400001)(966005)(83380400001)(186003)(19627235002)(2906002)(52536014)(5660300002)(8936002)(55016003)(110136005)(6636002)(316002)(64756008)(66446008)(66476007)(66556008)(76116006)(8676002)(66946007)(38100700002)(38070700005)(33656002)(82960400001)(86362001)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?UrSFOiPRrXLBjzDaNtGukUq5rqR2a1/9MvJeheuxH3Yk2h4xNiIk9NV90V1z?= =?us-ascii?Q?Fxdm56Slgufh5djDQrOr0WQlrtVAb/s24oagkb18L1L0/hd+a6TX+mPvRiyJ?= =?us-ascii?Q?dULG2PbMOH8fg8Y6Ht1YfgbvfjC3wwdIX0Lf2WEyp55WRyJSBmHmE7z8t0PA?= =?us-ascii?Q?SOCmEXC270g6j0Xfh/sg9cIdl7+svf68JCWmXg3MDOR9ihNPWZ6juWH8Geul?= =?us-ascii?Q?6d0CB8PRFv0oBFa4JBrLrti0mHV5V0uejxem+fmw2dL2ztwcHN4aZTw4xUjb?= =?us-ascii?Q?j4KPPrYl6kAX8wxfO8Q79JHzRefFk9QoJBuSh5fJY8s2g1uru9KPUEotXjWA?= =?us-ascii?Q?534ckQ74LEojemP+s+U1J3Q/Rx/pPnQ2M3b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VnP3Eq3TcxKmYW4SNSvYHq5dnfQLj1U5uTfEBupG0O+Ugl2w7cOoO+VheU?= =?us-ascii?Q?2gonMR4YNeRS3fslFZYYzhJvSuyJOhKKyCJtzCgYtl2+f/auvehRdk80u2Xx?= =?us-ascii?Q?vvCiHAv1JUJiRokpgnUZmEt/zBsXoYOTSJCE2CvKq/VxQyoGa+CHnFd4m4Qn?= =?us-ascii?Q?2Fxlju0f2TSjhFKAlgVOqaSwbQQUadm7TCSkUXa01bkW4c0nMENiZ1Q/uvO2?= =?us-ascii?Q?9skgG+8jSMVFU1OGteK1FOGF4sH3/r5xxGUHQohypM9FNWUCPFuMQofs9PwW?= =?us-ascii?Q?d/WVigFoDb7R5ETbNF76b+qdJ/KMIKIT3h9OcHs8?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN6PR11MB1908.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfb74f58-ac53-4312-c203-08da84b1835e X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Aug 2022 02:45:17.3824 (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: dRFCzALPfd4K1ch6dH4p6KaMu+bAlQIEWDYUGiu9Dig5kGhQywncC+BJ7RV/vEt+HI9VZCTubJG5b5DW4RrPZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2587 Return-Path: james.lu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: James Lu Thanks, James -----Original Message----- From: devel@edk2.groups.io On Behalf Of GregX Yeh Sent: Thursday, August 11, 2022 2:29 PM To: devel@edk2.groups.io Cc: Yeh, GregX Subject: [edk2-devel] [PATCH] UefiPayloadPkg: Fix Coverity report defect From: Gregx Yeh https://bugzilla.tianocore.org/show_bug.cgi?id=3D4018 Coverity report FORWARD_NULL and OVERFLOW_BEFORE_WIDEN potential defect in = UefiPayloadPkg. Signed-off-by: Gregx Yeh --- UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 4 ++-- UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c | 2 +- UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/U= efiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c index 9847063d3d..790e6109c0 100644 --- a/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/UefiPayloadPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -232,11 +232,11 @@ PciHostBridgeFreeRootBridges ( UINTN Count ) {- if ((Bridges =3D=3D NULL) && (Count =3D= =3D 0)) {+ if ((Bridges =3D=3D NULL) || (Count =3D=3D 0)) { return; = } - ASSERT (Bridges !=3D NULL && Count > 0);+ ASSERT (Bridges !=3D NULL |= | Count > 0); do { --Count;diff --git a/UefiPayloadPkg/PayloadLoader= Peim/ElfLib/ElfLib.c b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c index 2a6305c67b..a9bf6f3223 100644 --- a/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c +++ b/UefiPayloadPkg/PayloadLoaderPeim/ElfLib/ElfLib.c @@ -149,7 +149,7 @@ CalculateElfFileSize ( FileSize2 =3D Elf32Hdr->e_shoff + Elf32Hdr->e_shentsize * Elf32Hdr->e_= shnum; } else if (ElfCt->EiClass =3D=3D ELFCLASS64) { Elf64Hdr =3D (= Elf64_Ehdr *)ElfCt->FileBase;- FileSize2 =3D (UINTN)(Elf64Hdr->e_shoff += Elf64Hdr->e_shentsize * Elf64Hdr->e_shnum);+ FileSize2 =3D ((UINTN)Elf6= 4Hdr->e_shoff + (UINTN)(Elf64Hdr->e_shentsize * Elf64Hdr->e_shnum)); } = *FileSize =3D MAX (FileSize1, FileSize2);diff --git a/UefiPayloadPkg/UefiP= ayloadEntry/X64/VirtualMemory.c b/UefiPayloadPkg/UefiPayloadEntry/X64/Virtu= alMemory.c index 74b667a62a..8d8a9d0ca8 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c @@ -783,9 +783,9 @@ CreateIdentityMappingPageTables ( // Pre-allocate big pages to avoid later allocations. // if (!Page1G= Support) {- TotalPagesNum =3D ((NumberOfPdpEntriesNeeded + 1) * NumberOf= Pml4EntriesNeeded + 1) * NumberOfPml5EntriesNeeded + 1;+ TotalPagesNum = =3D (UINTN)((NumberOfPdpEntriesNeeded + 1) * NumberOfPml4EntriesNeeded + 1)= * NumberOfPml5EntriesNeeded + 1; } else {- TotalPagesNum =3D (NumberO= fPml4EntriesNeeded + 1) * NumberOfPml5EntriesNeeded + 1;+ TotalPagesNum = =3D (UINTN)(NumberOfPml4EntriesNeeded + 1) * NumberOfPml5EntriesNeeded + 1;= } //--=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92341): https://edk2.groups.io/g/devel/message/92341 Mute This Topic: https://groups.io/mt/92953360/4822895 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [james.lu@intel.com] -=3D= -=3D-=3D-=3D-=3D-=3D