From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.44]) by mx.groups.io with SMTP id smtpd.web11.6545.1676381283587315637 for ; Tue, 14 Feb 2023 05:28:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@ami.com header.s=selector1 header.b=kgO236eH; spf=pass (domain: ami.com, ip: 40.107.92.44, mailfrom: igork@ami.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OybBy/iG3ZzN/Q594o/sW9W1+PpbVz0u5MubauBleEVALBbiPhpUeI1i/t4xji1CCnfOqQyugJ2dNA2sQ44UWL00UaLxWgXRRXWnV2Ri9r8y9buXadeaPDixap4mDuQen5TUa7Q6feBgqQJjSdQuAUn1QMOIwtNDcx8c/hpCv/VmcUcUwVzLM8VT7y1yA+bA/pu4oibq4hXqT5FTUA1GCQO1WDoKABpVtOSGL/HupQfCmGhnN3AYGadhJsD26AYoVFZJdhN6GGkVRn6TPPiHwVKXutkiy+U1/LMlzX7r7x6zIXadd8fCeRc5NiI2acVH63HhV8BthjHltkv+Qkb67w== 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=9EFCrgrjvZjUr9M9rhTOJen38FUUxrlaG0lZ4xoqPSU=; b=QJYR7fMG6PIlJJvb4m6SvVyFXB+K4alvIEr57VlzTlF+XMCDquJj90mUfyWE3bMvX9DEcvpIxD56vAoTSQBHArSkDKJTUgLRCFNZoe1mOvN8nT4LWKxbNtJTlBNfPNxLvShjVW2Bf9g35bm8gnXqD2PytNU5Wfo59N/qNCNJm0EaeYdo4FnAMs6Yb9ZRIZJu6wV4lU0VPrs27S/47vxRr392p1DfKqXUA8b3ifl40QtUyFtNXV1ysnZdT+Epph1HV9txHPdMOaEEO2FUOmJxfgbU43FwJBkXqCt8W0QToFXDE2gO5wvqTEqNAeHtr5gXTKP3HXijlzXFlHRD7S5kPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ami.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9EFCrgrjvZjUr9M9rhTOJen38FUUxrlaG0lZ4xoqPSU=; b=kgO236eHiJ96hO1fpnJBBII238vTVPiuBN2nxHJX1LB0uuHtlIi41OGofQoSCR3QtPYSt7mAKpYjZ4+epqyDUp1D5aODT+Mg0n4UDavz7xwEvWWfo6r4so66yex4hlLInSm3tbJJIWb66pv8k/aXsVRm8Np2PeOUiEE0bqvN2Pc= Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by BL3PR10MB6090.namprd10.prod.outlook.com (2603:10b6:208:3b6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.10; Tue, 14 Feb 2023 13:28:01 +0000 Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::3318:8f42:7036:dbbf]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::3318:8f42:7036:dbbf%7]) with mapi id 15.20.6111.010; Tue, 14 Feb 2023 13:28:01 +0000 From: "Igor Kulchytskyy" To: "Chang, Abner" , "devel@edk2.groups.io" CC: Nickle Wang Subject: Re: [PATCH] RedfishPkg/RedfishConfigHandler: fix FreePool issue Thread-Topic: [EXTERNAL] RE: [PATCH] RedfishPkg/RedfishConfigHandler: fix FreePool issue Thread-Index: AQHZPZilEIQF9jbSNUWIb1BsPDQTja7OBK7wgABwN6A= Date: Tue, 14 Feb 2023 13:28:01 +0000 Message-ID: References: <1676065369-10396-1-git-send-email-igork@ami.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-02-14T06:55:05Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=16fd8c28-bc13-4d7b-8005-4bbf1f523c73; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=ami.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|BL3PR10MB6090:EE_ x-ms-office365-filtering-correlation-id: 41b290ee-ec72-4ed0-ebed-08db0e8f4b96 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: QDYJp+fhQnUOSRrwODS+Ho9g5+K7sWCGm49kNS1O4KkqKFG9n4dDRzwUlBE3jY8KCaD2Vj0MS9CvfDUq3qKWBCRCuptdfCuKjNzsuHGxHh1CtEpo2WtjeiSAqEONfOoSAkwAFrZMQw9gOP75/SMisNfZn/WXvcifTJRcWcXQ+EBJ9bh/jsKM5dXTfM3cBQXOtBEIw3291jTDgBwBStlSbkeqa//XRLKmYEV1xuvCoU2/2lZQ06j5gf9r9oB9xagnFBkasZIrgMBmQvH8/3UGVC0ti0EciI64qy0EviVCS3eTo9kSQJyhfMzej9BG0QivGOIanQWGN3XwT1of8vEvvoxd8Cvcy1Q+NPKztpndTrwgoRq7N1594vlKYRTlvogS+xWdV86Y2W/OEDgA6iYjuGqPIVkfwxX6Vgm/f4VL9EwfvlmQVxPa7q1A5e+G6YJFZFJ2lK7WwkfZbtCJZz9Otl9CtEehW6O9Vnhj5gpnDSjKy7/R8rXu+fOUZtLqbTUEiAOvio2E81Y/EkR9D5yJhgh6PVFcdWDEL4qrHAuqum3yJbaX5l38upa+7SQKHbWUJMHEt2LE/VcwTEbtF9wG0bl8ELJI7WLpvOUJai1c9eoCstbYJhQZ4ehbNV7M2dgxDQ7iLpbp7Mc6Z+u63q4L85IoYrilwY6pDvam2UFpUWQavrA6ouBsoa4u5TRWrbSvNQTUbXQ062H3Ddr651xqvQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BLAPR10MB5185.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(39850400004)(366004)(396003)(376002)(136003)(451199018)(4326008)(8676002)(66946007)(64756008)(76116006)(66556008)(66446008)(66476007)(122000001)(478600001)(38070700005)(33656002)(5660300002)(71200400001)(26005)(186003)(83380400001)(9686003)(52536014)(8936002)(2906002)(316002)(40140700001)(6506007)(53546011)(41300700001)(86362001)(7696005)(110136005)(55016003)(38100700002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?+UUfciFoP2dcyl7mdBZNb5VqYiyf/wcJ74uemuJyd9B4UPPBP5NaGrX80ROx?= =?us-ascii?Q?Lqvie5zyyFs56pYLWdtb4EmhZmBXja6kb9E1hSb9gE6SPUduVlg8aOCbKMz6?= =?us-ascii?Q?699RjJQ+vBdvxZidK4HmmxRd2gt6YtDV2A4Qkj87NhV6wXxmwQrVBQcDyfG5?= =?us-ascii?Q?j7Iaa2cM0SJhokdCDFLA6HGsHHk3bnrVszekSCFWrfqJzrvYtMGIKYhki5Fd?= =?us-ascii?Q?twHV64hnnbJn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?= =?us-ascii?Q?7KK31P4K819B/2K/CYCqUIB//d/ZTm6LC96kgOujn8lMaI1vGINeO1VAtXGb?= =?us-ascii?Q?Qn133Q+1NxveuuKgCA5IskfuJ8IN29/IDT/gM14cx8ZA5I+RtyLUuat9D95v?= =?us-ascii?Q?OTCH7x5u/Yp6m1z89tnnIIOIsGy5/mEItBsu7HCJXh7bWZERs+VvrWMN99J7?= =?us-ascii?Q?oxWuwTjn/TFQbFF26IUXMykrI/aQsYiTlAzl4P+ebg/wQLmIBMkcLnmGD5AE?= =?us-ascii?Q?v6PkokpwFf/cgEevOV9wiMVdcZEgc48TwhAaQ4B8GVdL28L41zJdbbYPCx9f?= =?us-ascii?Q?i7epwoRbUlSWu9kopgz2rnAW0uLqc6iaY5W0nMATgBPSV268klcP8DzPeszI?= =?us-ascii?Q?zVyhAoMk7xjMcMRCRojZhMGvxaiTqBh29TQDkoLhXcKm6Ks15+oKlCLjbpe5?= =?us-ascii?Q?CnyssM0ezhDAD+tCHvQ=3D?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41b290ee-ec72-4ed0-ebed-08db0e8f4b96 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2023 13:28:01.4037 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aH9Rho3eblbCGdfIErAsf8/DiubG0jnKrFC7yyVEnh2QwVJMNWryFYp358FNgNJR X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6090 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Abner, Yes, I will work on this to create the linked list. Thank you, Igor -----Original Message----- From: Chang, Abner Sent: Tuesday, February 14, 2023 1:55 AM To: Igor Kulchytskyy ; devel@edk2.groups.io Cc: Nickle Wang Subject: [EXTERNAL] RE: [PATCH] RedfishPkg/RedfishConfigHandler: fix FreePo= ol issue **CAUTION: The e-mail below is from an external source. Please exercise cau= tion before opening attachments, clicking links, or following guidance.** [AMD Official Use Only - General] Hi Igor, Thanks for catching this issue, I have a comment below inline. > -----Original Message----- > From: Igor Kulchytskyy > Sent: Saturday, February 11, 2023 5:43 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Nickle Wang > > Subject: [PATCH] RedfishPkg/RedfishConfigHandler: fix FreePool issue > > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. > > > gRedfishDiscoveredToken buffer is allocated as one piece during protocol > installed process, but deleted by parts during driver unload process. > > Cc: Abner Chang > Cc: Nickle Wang > Cc: Igor Kulchytskyy > Signed-off-by: Igor Kulchytskyy > --- > RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > index 96ac70f418..64b7fb7841 100644 > --- a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > +++ b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > @@ -481,6 +481,7 @@ RedfishDiscoverProtocolInstalled ( > ErrorReturn: > if (gRedfishDiscoveredToken !=3D NULL) { > FreePool (gRedfishDiscoveredToken); > + gRedfishDiscoveredToken =3D NULL; > } > } > > @@ -511,10 +512,10 @@ RedfishConfigHandlerDriverUnload ( > gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); > } > > - FreePool (ThisRedfishDiscoveredToken); > ThisRedfishDiscoveredToken++; > } > > + FreePool (gRedfishDiscoveredToken); I found here is a potential issue of gRedfishDiscoveredToken: Due to RedfishDiscoverProtocolInstalled() may be called more than once in t= he case of multiple NIC installed on the system, means gRedfishDiscoveredTo= ken will be overwritten by AllocateZeroPool() and result in memory leakage = when unload the RedfishConfigHandler driver. Could you please help to create an linked list (e.g. mRedfishDiscoveredToke= nList) to record the newly allocated memory for gRedfishDiscoveredToken (I = think we can rename it to just RedfishDiscoveredToken)? So we can go through the link list to free RedfishDiscoveredToken allocated= for each NIC when unload the driver. Does this make sense? Thanks Abner > gRedfishDiscoveredToken =3D NULL; > } > > -- > 2.37.1.windows.1 > -The information contained in this message may be confidential and > proprietary to American Megatrends (AMI). This communication is intended > to be read only by the individual or entity to whom it is addressed or by= their > designee. If the reader of this message is not the intended recipient, yo= u are > on notice that any distribution of this message, in any form, is strictly > prohibited. Please promptly notify the sender by reply e-mail or by > telephone at 770-246-8600, and then delete or destroy all copies of the > transmission. -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission= .