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 0F205740039 for ; Mon, 11 Mar 2024 13:18:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=m6Wz8dxDAqN/XaPhXAqtF9FINOCgDacQaCaxryL4zkI=; c=relaxed/simple; d=groups.io; h=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=20240206; t=1710163134; v=1; b=YVvY87fF8sah/1h9xXqPZMGFKVI7H5rXpCfYm8BIX76O+IkFl/wWkDBIcO3xwJRVm/xDIIpY hOwvHbqg/TZ3dCR7l8mVooZ5BhA8TuPdjWJtybawYmnQ52xqmLZ91WedP4fiAX0Q4INgs5jCwGD HnDww8Cc792AOOzfn60eB2M5NgL+TTTkVZ/f4m/N8OLsoTqQI5S11tsFX28esPtUzxLiF5dYfji +ei17OJRJRU/jgsjop3+siZKMgCjO1dsLBRKUl/V0xr3jwsqlD+kONMGVoXuLCjeBkH+ye9BFbB H2KNg3J3B3V9vkbDtT812hj7BKEDpguQW/mwc9NcyVLsA== X-Received: by 127.0.0.2 with SMTP id n8YzYY7687511xhdfbD0p7wt; Mon, 11 Mar 2024 06:18:54 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.72]) by mx.groups.io with SMTP id smtpd.web10.62517.1710163134222794186 for ; Mon, 11 Mar 2024 06:18:54 -0700 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by CYYPR12MB8750.namprd12.prod.outlook.com (2603:10b6:930:be::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.34; Mon, 11 Mar 2024 13:18:48 +0000 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::fef9:2c9c:21b5:6f50]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::fef9:2c9c:21b5:6f50%2]) with mapi id 15.20.7362.035; Mon, 11 Mar 2024 13:18:48 +0000 From: "Nickle Wang via groups.io" To: "devel@edk2.groups.io" , "mike.maslenkin@gmail.com" CC: Abner Chang , Igor Kulchytskyy Subject: Re: [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions Thread-Topic: [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: fix leak in provisioning properties functions Thread-Index: AQHacteWzGPFB7J65E+G6+OoHfOd0rEyh52Q Date: Mon, 11 Mar 2024 06:18:54 -0700 Message-ID: References: <20240310104151.41355-1-mike.maslenkin@gmail.com> <20240310104151.41355-4-mike.maslenkin@gmail.com> In-Reply-To: <20240310104151.41355-4-mike.maslenkin@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|CYYPR12MB8750:EE_ x-ms-office365-filtering-correlation-id: aeb7e3e8-ded0-4d20-43ba-08dc41cdc994 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 60SmhfOmT0RakN2RxvqPC+EktGSs84whPIzMu0FsjPA7OFGmXMjT+ocCfYzZ4QJG6avNXafC1av22MhdySqw5j3WVMVFBUY0r7IommiJisTx4w3qmYLDK9sUlcuvAVCzFNVz4zxj06+Du9HBcdGsEoBXIzWL8QiWNv5xj/6OK4sNwnbcWzZSPctR2BE5X6u9RhlaOd1Jgvx93SR4yMoJb2ewC9gBIpEQZKIrh4Re6jStEBqypQsUeTdYNfi7E8ZyzzHqxLj1vhHvEMfeQZw3cxjKDLox/q5RemQDwS59oGyej+fUNzrCgOrSluHj85zm/7BSpeMZWm9rYouGQOBvuJmJe9My28OS1M52wvX1XnOgEGDSdBLbwHjAGVqXGcK/XZTiqRIKEJUKNguvyvuL3pLRmifYlhSLXGR8gxcu1MoN69gKV4zvkp32XrdenhEpH7UkjX7ByFjHklz1QpWw+keb5DrprMpxWXyYcDn1sdN7D/V8fjbfV3Z8IHJNGwZDs7BJkRPJ8BYDDnsIbX4ZkVA3phFGqFMleDVSIIj/1SkVF9r2f10iTRb+50L0iIccGqEftxNOYWxbAt/MopCFv6OGVXXSKFAja+ieUoG4ZPgzjUUXxU7lpsih23LVwxG0NIfGUSi5e9FgEaWu9bjEnnaMVbbHzZtVRu2BSnwWEfM= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?OalOeQKW8UTKF6S7mczCrUo99WiJGLhho5BkiKu3cqchRje8SsjEtmLnUtl8?= =?us-ascii?Q?ALe7gawby/3fz9v1c6Z8+XZO9DzOAhRx6eCWl6Vee8bcyt+uks/Vvtz61on4?= =?us-ascii?Q?W2UL599hgYoWS+KEkxrz4snVDjlE25dPdQqcMUDNRNzh/CYwumUn/ddgJavU?= =?us-ascii?Q?uCN0bi46si7be334Jaep2O9MRg3E+bBzazw3bwdpf/+NQagDWsNUjhOyOX4v?= =?us-ascii?Q?MO4mTk4IJ2vx8htdtj14jUFRxIihwOr0MFQuR+280ztrdSPLIs89C1lcMzdT?= =?us-ascii?Q?knTbIUYtjb1J9m3lu0QuGT3AEdutZp9NbX8/OG0eP5pukbbEUQlV1oW3YhPT?= =?us-ascii?Q?pkO64vyAEW7GxmSZf9OiUI/U1bXBxdNqN/0gghGqWb+E3No7ctFmsO7YaidW?= =?us-ascii?Q?uIxlvXshtFGL0DLWlDGrHYtby3E+icqVK43O+a6Z2dEbZcxZa0Iac/JcbgGz?= =?us-ascii?Q?SfFC92esoR/Q2ZRHeW3l3HTEjtj1aepltm8nyVH2ccnxCLeZ5/tg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1eFdf/crORAXWV/oirh0iKJhThnP2HwRjGdqqUaaqi+w6eKIagFry41?= =?us-ascii?Q?aVlf8jELiPYDJyjLGMmoKf5nJ7etNrXh9rnSv35osQF2kOa0SkAVspSbyYkm?= =?us-ascii?Q?ZjrU931OtwKquqJSAxETyCrsWdBtUmaDcUoX8j/FjhHmfzK1s56fGdEN+4K1?= =?us-ascii?Q?axIMsNh3iGQm4+VCg1WCx+2qtjljjT8AryAQD0ba?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: aeb7e3e8-ded0-4d20-43ba-08dc41cdc994 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2024 13:18:48.5178 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: b0fHoDalonbDAhNzwijuaarN4lBUtAmr3N2Z+XPE+QuJWOpGWoWjCTyXg7BLTcj+MBsrJKjAqwgcbx9cOfTcOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8750 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 9BhbyoSJpem3IfyccpOqyb3Cx7686176AA= 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=20240206 header.b=YVvY87fF; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Nickle Wang Regards, Nickle > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Mike > Maslenkin via groups.io > Sent: Sunday, March 10, 2024 6:42 PM > To: devel@edk2.groups.io > Cc: Mike Maslenkin ; Abner Chang > ; Igor Kulchytskyy ; Nickle Wang > > Subject: [edk2-devel] [PATCH 3/4][edk2-redfish-client] RedfishClientPkg: = fix leak > in provisioning properties functions >=20 > External email: Use caution opening links or attachments >=20 >=20 > The structure instance retunred by ToStructure() must be deallocated prop= erly. >=20 > Cc: Abner Chang > Cc: Igor Kulchytskyy > Cc: Nickle Wang > Signed-off-by: Mike Maslenkin > --- > .../v1_13_0/Common/ComputerSystemCommon.c | 25 +++++++++++++------ > .../v1_5_0/Common/ComputerSystemCommon.c | 25 +++++++++++++------ > 2 files changed, 36 insertions(+), 14 deletions(-) >=20 > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.c > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.c > index df22a1c90c46..4795e4d6c6eb 100644 > --- > a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyst > emCommon.c > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSy > +++ stemCommon.c > @@ -263,7 +263,7 @@ ProvisioningComputerSystemProperties ( > ); >=20 > if (EFI_ERROR (Status)) { >=20 > DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Stat= us)); >=20 > - return Status; >=20 > + goto ON_RELEASE; >=20 > } >=20 >=20 >=20 > ComputerSystemCs =3D ComputerSystem->ComputerSystem; >=20 > @@ -365,7 +365,7 @@ ProvisioningComputerSystemProperties ( > ); >=20 > if (EFI_ERROR (Status)) { >=20 > DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status))= ; >=20 > - return Status; >=20 > + goto ON_RELEASE; >=20 > } >=20 >=20 >=20 > if (PropertyChanged) { >=20 > @@ -374,10 +374,14 @@ ProvisioningComputerSystemProperties ( > if (EFI_ERROR (Status)) { >=20 > DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable > properties from ResultJson.\n", __func__)); >=20 > *ResultJson =3D NULL; >=20 > - return Status; >=20 > + goto ON_RELEASE; >=20 > } >=20 > } >=20 >=20 >=20 > + Status =3D EFI_SUCCESS; >=20 > + >=20 > +ON_RELEASE: >=20 > + >=20 > // >=20 > // Release resource. >=20 > // >=20 > @@ -393,10 +397,17 @@ ProvisioningComputerSystemProperties ( > DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, > ArraySize); >=20 > } >=20 >=20 >=20 > - JsonStructProtocol->DestoryStructure ( >=20 > - JsonStructProtocol, >=20 > - (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem= Empty >=20 > - ); >=20 > + if (ComputerSystemEmpty !=3D NULL) { >=20 > + JsonStructProtocol->DestoryStructure ( >=20 > + JsonStructProtocol, >=20 > + (EFI_REST_JSON_STRUCTURE_HEADER > + *)ComputerSystemEmpty >=20 > + ); >=20 > + } >=20 > + >=20 > + if (EFI_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); >=20 > } >=20 >=20 >=20 > diff --git > a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSyste > mCommon.c > b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSyste > mCommon.c > index c383cad59029..2d257e01da2b 100644 > --- > a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSyste > mCommon.c > +++ > b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSys > +++ temCommon.c > @@ -793,7 +793,7 @@ ProvisioningComputerSystemProperties ( > ); >=20 > if (EFI_ERROR (Status)) { >=20 > DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Stat= us)); >=20 > - return Status; >=20 > + goto ON_RELEASE; >=20 > } >=20 >=20 >=20 > ComputerSystemCs =3D ComputerSystem->ComputerSystem; >=20 > @@ -1235,7 +1235,7 @@ ProvisioningComputerSystemProperties ( > ); >=20 > if (EFI_ERROR (Status)) { >=20 > DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status))= ; >=20 > - return Status; >=20 > + goto ON_RELEASE; >=20 > } >=20 >=20 >=20 > if (PropertyChanged) { >=20 > @@ -1244,10 +1244,14 @@ ProvisioningComputerSystemProperties ( > if (EFI_ERROR (Status)) { >=20 > DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable > properties from ResultJson.\n", __func__)); >=20 > *ResultJson =3D NULL; >=20 > - return Status; >=20 > + goto ON_RELEASE; >=20 > } >=20 > } >=20 >=20 >=20 > + Status =3D EFI_SUCCESS; >=20 > + >=20 > +ON_RELEASE: >=20 > + >=20 > // >=20 > // Release resource. >=20 > // >=20 > @@ -1263,10 +1267,17 @@ ProvisioningComputerSystemProperties ( > DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, > ArraySize); >=20 > } >=20 >=20 >=20 > - JsonStructProtocol->DestoryStructure ( >=20 > - JsonStructProtocol, >=20 > - (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem= Empty >=20 > - ); >=20 > + if (ComputerSystemEmpty !=3D NULL) { >=20 > + JsonStructProtocol->DestoryStructure ( >=20 > + JsonStructProtocol, >=20 > + (EFI_REST_JSON_STRUCTURE_HEADER > + *)ComputerSystemEmpty >=20 > + ); >=20 > + } >=20 > + >=20 > + if (EFI_ERROR (Status)) { >=20 > + return Status; >=20 > + } >=20 > + >=20 > return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND); >=20 > } >=20 >=20 >=20 > -- > 2.32.0 (Apple Git-132) >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#116567): https://edk2.groups.io/g/devel/message/11656= 7 > Mute This Topic: https://groups.io/mt/104841894/7129762 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [nicklew@nvidia.com] -= =3D-=3D- > =3D-=3D-=3D-=3D >=20 -=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 (#116626): https://edk2.groups.io/g/devel/message/116626 Mute This Topic: https://groups.io/mt/104841894/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-