From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.208860.1673987555407026035 for ; Tue, 17 Jan 2023 12:32:35 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=UgWtczW3; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: isaac.w.oram@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673987555; x=1705523555; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=37NSPZMRdwhEz3b9cglKzyalaSCwDeWMQSRDeXIfq5k=; b=UgWtczW3fjUb1JsMuiRDxBwaXMR7Fmgi2WhVQ6LDLTTlVgUOLWfjlkTX Q7bMmSwc6m0fDiTedET1GCGiCgDdlVTuiJHACL9ltfq5O3DW3u7H5FfqM HMxuraVU6OQuB6DnBPb/4auiWHimMqpWWRQnl1I2vt7sy2Z/VHQmYMVtb P9DOfoTMRV2INvf0pt97h1vPA7vDwboFGN0nWPfs/EtRSVdLu5RNxsYIz ciIe8auoAj/zCxZT2ekFRKNh6+DD6fOS0nfSb30ffxUBlb9xhdpJFYrLv oAzrajurdpU6RjuTl8KY+tkae3NJMeCep3vpUbke/RpGR2y9EFNKjCl20 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10593"; a="326885263" X-IronPort-AV: E=Sophos;i="5.97,224,1669104000"; d="scan'208";a="326885263" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2023 12:31:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10593"; a="833301935" X-IronPort-AV: E=Sophos;i="5.97,224,1669104000"; d="scan'208";a="833301935" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP; 17 Jan 2023 12:31:30 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 12:31:29 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 17 Jan 2023 12:31:29 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Tue, 17 Jan 2023 12:31:29 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.174) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Tue, 17 Jan 2023 12:31:29 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kQUgyVWWRdFS3GEpD+wX4J7NIDmL6Jf5lSkRkMmoayPY2NXUx9jWHvjXhQR04jJcjL8bkJEqei1AA+RQwGt+qmR/OFBHUY+xCSU6Tvp/ry7mthUNoRMgU6QG1qaDF7qDCVtPvBFSkvqDGTd2VvBzbG4I9yyucG+0UieWDeEo5KJoqmW9PdroppWFrlL1et9mJEqzSo8tRQGlxYWL//KY2cikhr4m8LNO2URMMm3gWL1Wb/sdZ9LFLcvEPcJoolhsKb9gNQrsMDtobnOBtORJMcjHG21OXEgaM3WgapL5BmfVGYe4KTuB+elEq77iAFvykv4Lcgx5ddrP5kT2smiScw== 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=9D9pLKP9BRiBCrR4kbjEyELGQ0WlnqB2Ux2NdF85WLE=; b=EU09fqDe29rCiaHxmMp1ZLAHzvsmt0s0bEU5czlKsFt1NvCYh1lNRATr1rAD+DkKaHV3zWsV0zkrxlvFG300bV2vOC5f43VqsDwbXZ/4Nu/6PI4DQFZcbdDnkv7oeUGBxbuh/bZZztBV+fBQBNWWHzaBYjK5lmA2EGRc8HiHaSIFkYnRsK//FPBb5tmCAb5MIRULKeTzj+KtH0fX+KcssKGU8mQEe2n08HTbiW06CJdcWhNkr9ErnRG00JymmX5EUffpBDaarUhJFo4Zj4/858l/I6lrpVnniNjvKUSryl4LnumFodw1K4Pw3GOBQN/UeiaC6+d0brKHXCcaih4Zbw== 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 SA1PR11MB5801.namprd11.prod.outlook.com (2603:10b6:806:23d::13) by SA2PR11MB5195.namprd11.prod.outlook.com (2603:10b6:806:11a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Tue, 17 Jan 2023 20:31:26 +0000 Received: from SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::7623:38f5:ab31:61a5]) by SA1PR11MB5801.namprd11.prod.outlook.com ([fe80::7623:38f5:ab31:61a5%5]) with mapi id 15.20.5986.019; Tue, 17 Jan 2023 20:31:26 +0000 From: "Isaac Oram" To: "devel@edk2.groups.io" , "AbdulLateef.Attar@amd.com" CC: "Dong, Eric" , "Gao, Liming" Subject: Re: [edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path before processing Thread-Topic: [edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path before processing Thread-Index: AQHY+Qy6pK8QirXJck2NqGT/9E29Ba6jZ8Aw Date: Tue, 17 Jan 2023 20:31:26 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US 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: SA1PR11MB5801:EE_|SA2PR11MB5195:EE_ x-ms-office365-filtering-correlation-id: 8e430e3c-fe6e-46c6-a3b4-08daf8c9cea8 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DDs3/lXmi7zfwyp09x4WkHBL8t8eV+bYNGDT3BUtK1I+XGygAq5T63gWV/QoXX7KyJggVEsexwRnCn6YNMB7LYfTQ2M7zCzhvXoydA+EsiripBjLxBKl18jSJWu0Fk6P2gM5jkCSJsT9YFe8w+FPIANuFmczQkWe9bkMip0ay863Wz7NtFdHHhXDzxcRbcBrOaX+RycL5zDzLE61XaGMmDHOe2hfR15/ckp2QQrDe7eCNSKMol7g5JVSJLAyzeq0TLWioKv+G255mkv8kwSEn8THQgfgMNJW8Ug/jEs5z+lM/AT1cI2+0N43bU0Up8Et1viyigfJ4cIMp5mkTsrALb50NR8XqmScv96F63hhYsRyDRtMyJL01fYKYtC37Ubes6kONgdWp5n33BfI9PbaSqNaipCLRj/ZPo6eomVENMNUfV8T+lsJLtlc7kOQfDvPsI2TQyreXXt27PPa8wQoSrnasKR8XbVR0I6lpVsUP+NyqkEUcse/okegvhCuKxqkhuJJlq+6Qn95stTZ2VpOt2eG23Sz0V4CA35rZwfEdPTBFDKgSSI3xDBK/86X6S01qj9Y0id/L5MUYVUmWcpnPbbjS6Ad1196OVEc5HNOOj+CD8YgiJOIBgDbytxWWHiQTvUzHx9PuzNS6Y58zpO0hXgWwiFtqC2nPhM42fNKoHv6U5V4zJP9tZL8f+i03MZPAbNswA7X5dY40MWe6Ux67gM9c4Kr03r7VaQfI2c4W69JpNY/87bRaEXtmvZ32qeHzZ7chJDTnWBxrWjIRXzeWw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB5801.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(376002)(346002)(39860400002)(396003)(451199015)(52536014)(8936002)(66899015)(966005)(82960400001)(5660300002)(8676002)(4326008)(33656002)(53546011)(26005)(66476007)(41300700001)(66946007)(76116006)(64756008)(66556008)(66446008)(2906002)(54906003)(316002)(86362001)(110136005)(55016003)(71200400001)(38070700005)(7696005)(478600001)(122000001)(38100700002)(186003)(9686003)(6506007)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?XrbbkEzLuo4mc2qifjixU4Jo6KZEssgvURMF8ICdHv0NFv+5pmeNSSqW7cXj?= =?us-ascii?Q?3nnW9BNpGfs5T442HwZL8rPcQ/hPBjkdxC8RshXp/s5wBU0QLHWAmKZPzlDm?= =?us-ascii?Q?U97FtG4IB+FQ/x5b+g84Kpr6TI5H+/T5kLZAuBZ781XVMQ6fhwB1LOJlsYLZ?= =?us-ascii?Q?/kyK2xaGhKrtWq7pUfTlxQlqiCt0HImyoqmZUd6UPuvWI+5Xf1U6DR874rrz?= =?us-ascii?Q?CZEWs56XpZ8kFS0Zcu7LgkziwUn4YcWMcJumx4VyxCUB3FvuNuy4PdEXzWeF?= =?us-ascii?Q?ZzOrJ4NmRycBRDC92Vo/ajm6fwW3Kw2f8gFAIVfFqJTAylnz3vDz/LqjV9a0?= =?us-ascii?Q?Jfihj9onxHt4IvAvOYwBRuW6hfA9aiq3RXI0wj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Vp94AhAr/jhHDpqd9lREJFN3WabOLwnwVD1e+q4F7ORYMNCO4yTsvs9?= =?us-ascii?Q?V3KLzB+jLsNEaMgiOfYjk9tzW9Z/IRweYCLpQD71q8dVYBjFeAvCKzLIdtep?= =?us-ascii?Q?2KwqbFAhYYKh3Igm0xaqLtbyLPKuJ46OpheRgQvmZb4EzuluzyI3xcNH8mXK?= =?us-ascii?Q?m22FhloMn8G1rbHUgLH4dyWLBloEnyFDlHGYuTki8xw8F/2UrnjszFcSRMYc?= =?us-ascii?Q?+pi/JYu7JK26ZFM2YNHC6LDvOBY7IRUSGXUFZdAJNwIaWk0VqQ8GN/aLQMwq?= =?us-ascii?Q?d7zYhjaRlJG+LWvAbH/MymtwTcbMBThZxvY+ttDz?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB5801.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e430e3c-fe6e-46c6-a3b4-08daf8c9cea8 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2023 20:31:26.5307 (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: hNYbVsUbWjZz9T8+tzi565E+fxjirelVvIEB1WntQ6iz6vzsWnHlllOXc/dhOVA6geosAaa+chD6nzlqZpDm9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5195 Return-Path: isaac.w.oram@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c=20 Line 168: Don't we need to free buffer on this path? Lines 655, 1083: Please put a newline between while and the block to free = resources. Regards, Isaac -----Original Message----- From: devel@edk2.groups.io On Behalf Of Abdul Lateef= Attar via groups.io Sent: Tuesday, November 15, 2022 4:04 AM To: devel@edk2.groups.io Cc: Dong, Eric ; Gao, Liming Subject: [edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path before p= rocessing From: Abdul Lateef Attar GCC compiler puts the DevicePath PCDs to the read-only section. During boot= if try to process the device path after PtrGetPtr it throws a page fault e= xception. Hence making a local copy using DuplicateDevicePath() to avoid the page fau= lt exception. Cc: Eric Dong Cc: Liming Gao Signed-off-by: Abdul Lateef Attar --- .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBds= HookLib.c b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsH= ookLib.c index 0bcee7c9a4ba..8700118d255a 100644 --- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib= .c +++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHook +++ Lib.c @@ -3,6 +3,7 @@ implementation instance of the BDS hook library =20 Copyright (c) 2019, Intel Corporation. All rights reserved.
+ Copyright (C) 2022 Advanced Micro Devices, Inc. All rights=20 + reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -131,7 +132,7 @@ IsTrustedConsole ( =20 switch (ConsoleType) { case ConIn: - TrustedConsoleDevicepath =3D PcdGetPtr (PcdTrustedConsoleInputDevice= Path); + TrustedConsoleDevicepath =3D DuplicateDevicePath (PcdGetPtr=20 + (PcdTrustedConsoleInputDevicePath)); break; case ConOut: // @@ -147,7 +148,7 @@ IsTrustedConsole ( TempDevicePath =3D NextDevicePathNode (TempDevicePath); } =20 - TrustedConsoleDevicepath =3D PcdGetPtr (PcdTrustedConsoleOutputDevic= ePath); + TrustedConsoleDevicepath =3D DuplicateDevicePath (PcdGetPtr=20 + (PcdTrustedConsoleOutputDevicePath)); break; default: ASSERT (FALSE); @@ -171,7 +172,9 @@ IsTrustedConsole ( } while (TempDevicePath !=3D NULL); =20 FreePool (ConsoleDevice); - + if (TrustedConsoleDevicepath !=3D NULL) { + FreePool (TrustedConsoleDevicepath); + } return FALSE; } =20 @@ -624,7 +627,7 @@ ConnectTrustedStorage ( EFI_STATUS Status; EFI_HANDLE DeviceHandle; =20 - TrustedStorageDevicepath =3D PcdGetPtr (PcdTrustedStorageDevicePath); + TrustedStorageDevicepath =3D DuplicateDevicePath (PcdGetPtr=20 + (PcdTrustedStorageDevicePath)); DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath); =20 TempDevicePath =3D TrustedStorageDevicepath; @@ -649,6 +652,9 @@ ConnectTrustedStorage ( =20 FreePool (Instance); } while (TempDevicePath !=3D NULL); + if (TrustedStorageDevicepath !=3D NULL) { + FreePool (TrustedStorageDevicepath); + } } =20 =20 @@ -1031,7 +1037,7 @@ AddConsoleVariable ( EFI_HANDLE GraphicsControllerHandle; EFI_DEVICE_PATH *GopDevicePath; =20 - TempDevicePath =3D ConsoleDevicePath; + TempDevicePath =3D DuplicateDevicePath (ConsoleDevicePath); do { Instance =3D GetNextDevicePathInstance (&TempDevicePath, &Size); if (Instance =3D=3D NULL) { @@ -1074,6 +1080,9 @@ AddConsoleVariable ( =20 FreePool (Instance); } while (TempDevicePath !=3D NULL); + if (TempDevicePath !=3D NULL) { + FreePool (TempDevicePath); + } } =20 =20 -- 2.25.1