From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web12.2707.1646977731010427851 for ; Thu, 10 Mar 2022 21:48:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=U4aLCqdt; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0069e0a9d6=abner.chang@hpe.com) Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22B52RP5028363; Fri, 11 Mar 2022 05:48:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=ATIG12wze7b7PoyrMOmrDYGJg4s/inmRuFTodD104DU=; b=U4aLCqdtSrjkMp8k+31LUjfIE8Wa/WCDG/R8Dzlpmk2EamTjoCTHvtstifbQ6msg/g8v cr4rIH8gB9iRIvgnuuaAucRMEgbkMEqMdVK7g1+DF/3YeBxBY91qzUiuoQQOIoimmYvL udiy670xQ3XkcZzWSI3Xxzsh+uzS2SAIM4B6ctYmU4TVuLJqSGSy1Z5QVyGuL6x/KxEk +r3jUiGB+/KwDX/RNp6V36t1UMObxINF1PAaT3x/6CwcOPVsJuNEHeCY5IbP8WkT+kJ3 uughFF2Fr/85indDj2apOFcmu3veSEx9lLO6sRbEzdCn6ANGwuoMB8KnE8gx8O++7IGs 2g== Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3eqv9tsrhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Mar 2022 05:48:50 +0000 Received: from G9W8456.americas.hpqcorp.net (g9w8456.houston.hp.com [16.216.161.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3426.houston.hpe.com (Postfix) with ESMTPS id 4CCD04F; Fri, 11 Mar 2022 05:48:49 +0000 (UTC) Received: from G1W8108.americas.hpqcorp.net (2002:10c1:483c::10c1:483c) by G9W8456.americas.hpqcorp.net (2002:10d8:a15f::10d8:a15f) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 11 Mar 2022 05:48:49 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (15.241.52.10) by G1W8108.americas.hpqcorp.net (16.193.72.60) with Microsoft SMTP Server (TLS) id 15.0.1497.23 via Frontend Transport; Fri, 11 Mar 2022 05:48:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwRfJl+VHYPzJekCo1kB5yJ7lQGeEqrvjFauASI3NRixXRy788GUKmlnttHPH5Gpd/1G7Dq7Z5qozgsV/Lw+EZZobd5jzWoIlEIWgwIoElV3LtyEEtlWKvLfRCG7J/vv474K3SAlgU8okdjekaVyqZJ3lrtuwZ0XJaF0gd/HJ1MnIX3atDl0gYiFeZesjTrB46eNik2Wljc7vN5we7G3LCPV8O+w0WP5eFITaOMbA21CDNtC+q+K0c65L42NKQ9mClb1/3/QD7AbOiTUf40sErUvcxNj9y4tOUQ4kmRIekllqkvQgeMhny85LXZydud0wcsFSiWTyPbCkJURZJBQPA== 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=ATIG12wze7b7PoyrMOmrDYGJg4s/inmRuFTodD104DU=; b=k+xPl3r4nhDD42MiNgV0re0HxVdnHbPYn7Hvvp9tn7tztPDfB/Xv9u7nxIhW2npbrV45urQcSlQ3wps7SkB6ntxCvO0LDYXStGv+zPgD2r74POM6jLiUAzmo5CERv+QFnzNqmaqtrsJfG5ECxcOUkSh0IwA8hp0Cv+5RIr1yGoSYAaB+imuVmLxkadp3pbe3as/DN6igBAdCGwSoFE5x5iuZOC4atq5iOMynG1/RG3n8fIH/ajdZTRhgAaKkd5XpNflEGYD40nfp15ldRXVXxREyVbzTboin1tEYVXlyLb88B5HziihKbDvj70fArBSrIS0yDn4JZ8g28LF7bYAxQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:510:154::18) by DM4PR84MB3005.NAMPRD84.PROD.OUTLOOK.COM (2603:10b6:8:41::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.15; Fri, 11 Mar 2022 05:48:47 +0000 Received: from PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM ([fe80::2053:811f:bd4a:7c21]) by PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM ([fe80::2053:811f:bd4a:7c21%7]) with mapi id 15.20.5061.021; Fri, 11 Mar 2022 05:48:47 +0000 From: "Abner Chang" To: Wenyi Xie , "devel@edk2.groups.io" , "Wang, Nickle (Server BIOS)" CC: "songdongkuang@huawei.com" Subject: Re: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue Thread-Topic: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue Thread-Index: AQHYNHHDHSXpfuBS4UOBxK3Ve9Tn7qy5rkvA Date: Fri, 11 Mar 2022 05:48:47 +0000 Message-ID: References: <20220310112534.2952545-1-xiewenyi2@huawei.com> <20220310112534.2952545-2-xiewenyi2@huawei.com> In-Reply-To: <20220310112534.2952545-2-xiewenyi2@huawei.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3ef7775c-0fc5-40ad-1960-08da0322cfc6 x-ms-traffictypediagnostic: DM4PR84MB3005:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wSInyIAXtd9RQpPNU44n2YpFrsKQTs+uTi9meDlavZCbbk6TwuUoqP9l6SnSqhw2dzULI2f658qTZxpFOIYIIg2oRECuguIp11bdaXn5oc2wI/oea+SypguM2UBqwOGrnCq7Fn8W06SGVy0gCOU8p32T3KI59TLpA5wDysbqPxq5nr7wjLUoJVEdtMhLSbL3/qDbuz3hJQEgs9Fm8U4PpznaX+xV61wb1Bjhwqkks63XaQkm0/mfLTDI1JUg5fLSGWtNDFuKpS7TcxI25sBLgUGdBIJtcVnJdO/qeSuicKHvpNU92E04A6aKJx4Cn7Xkl1uszGxYSMcpXp8FW9/CRyiBzcj5a4DAAprnkEm3WKBVFZc3PpLGk84ffecOtzT7k9IEsgNu6Mzqi0Rg2U0gLiOM2G1HFCOhKIildfYox/ANlYCyn5BFgXHMDNgIeeXS4TKw1QcBisdBRNkLbP38diT5QPoVkRHfx1FUDXZtsv0Nx71ixWzunF26URPQzKwUKmQsIWXIMkfOhzZr80flbf+QkzPflOLHBCT/BiaPGm6HcmhAGcEXLQ8NpfdYBpLtUJZhF4pITbQbVdJ+yMdX8IWBxUiCgzsWlol/qgFYqAv/kU2PuB2GgMnEV1ZqwvZLqzQGql+T8eC7t0C+coImosHgO+hEmXI22vNF1aoGLwi3kpdbHwcxTureO458PIYyGMO5/9DoJ7ZEu91v2l3EMA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(366004)(76116006)(316002)(66476007)(66446008)(66556008)(64756008)(82960400001)(4326008)(38070700005)(110136005)(9686003)(71200400001)(6636002)(122000001)(38100700002)(6506007)(66946007)(8676002)(83380400001)(26005)(508600001)(33656002)(186003)(55016003)(5660300002)(8936002)(52536014)(7696005)(86362001)(2906002)(53546011);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?NILSGTOX/krFge8kxkltcEuNxOXmfUkrIuUSoubCRf8Df4wHF+KUe1U23h2Z?= =?us-ascii?Q?hrCg76lUbEsKPFtP2hx+RAJxFlXm5UaFOar5/IG4zgBEpgSi9GJIYOdKPkAT?= =?us-ascii?Q?0C8RAC6LZRoU/0xZSQNGhI5+wGuqJaV0wl6CIG7l5p6eFJCy0rgJJUv9+iRI?= =?us-ascii?Q?lYpfjez8Njzs5Segpowu4ckTUA19gKsildPJDnphgYIb1g1pdZx+E2t9MA1+?= =?us-ascii?Q?yf5P2fH9vQjWaZ/IXD/bscryWbC7FyNWNptARZ2Smve6M7eB226v0TNMRpJs?= =?us-ascii?Q?zKYZAyxOWY4NBTlINco6rFbT1YMIYlvlbHmUwXed9j34RTbD0NbUunWG9BlK?= =?us-ascii?Q?6PP+j9dTH0QrKSEBzMU5Qv3Qwc84JJYvz15kPy36Gz/B2RKq+aA0uuxr957W?= =?us-ascii?Q?jdfhXdVCT7CB7oqbdgjJU/tKDcD1Lkx/FRy+8pJGMN0xjLc82fI50ZWDlokG?= =?us-ascii?Q?iyH/BXEQg4Aovb16hhmIn768qOIsdODCQFqWmZjWs1xrKhzmG+gcpsjxttzH?= =?us-ascii?Q?aqtKJ+WJYSQhyVZE+WI2+mRPiyGF89S0I4VIKHQLeB3hgpPHW6buF/b+TmRX?= =?us-ascii?Q?EoiEp6PkR9wx25iPWZemqe9SNIyXznbhY3/TaelEZtddbexElE0Amu/q2pJ5?= =?us-ascii?Q?/p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ZPla6mYV+dY9sF1B?= =?us-ascii?Q?jETaK9jmVUMhpsJsjBpES5pka8KK48TVcTSXLbvpBCVSvTG73OvUg/dWz95L?= =?us-ascii?Q?Z9wRPhjdb4DbHugOlKDkbkg=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR84MB1885.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 3ef7775c-0fc5-40ad-1960-08da0322cfc6 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2022 05:48:47.4266 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VL0cWJ/pph0wp71T1TY2Fr+rJTH91dk7eJ52HdaAwNZesd8MWk8crumRgh7muPoe0oO4N1M+St5ygvGsYnwkpw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR84MB3005 X-OriginatorOrg: hpe.com X-Proofpoint-ORIG-GUID: r1H8tyExJ7x5Aln07N_aH-M5drNrEepO X-Proofpoint-GUID: r1H8tyExJ7x5Aln07N_aH-M5drNrEepO X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-10_09,2022-03-11_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 mlxlogscore=944 malwarescore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1011 priorityscore=1501 phishscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203110026 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks for catching this. Reviewed-by: Abner Chang > -----Original Message----- > From: Wenyi Xie > Sent: Thursday, March 10, 2022 7:26 PM > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist) > ; Wang, Nickle (Server BIOS) > > Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com > Subject: [PATCH EDK2 v1 1/1] RedfishPkg: fix memory leak issue >=20 > The calloc memory is not free when function collectionEvalOp > return in the halfway. >=20 > Cc: Abner Chang > Cc: Nickle Wang > Signed-off-by: Wenyi Xie > --- > RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c | 16 > +++++++--------- > 1 file changed, 7 insertions(+), 9 deletions(-) >=20 > diff --git > a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > index 3f2b83e834d0..6c6e2246abe3 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > +++ b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c > @@ -620,6 +620,7 @@ collectionEvalOp ( > if (((*StatusCode =3D=3D NULL) && (members =3D=3D NULL)) || > ((*StatusCode !=3D NULL) && ((**StatusCode < HTTP_STATUS_200_OK) |= | > (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)))) > { > + free (valid); > return members; > } >=20 > @@ -633,6 +634,7 @@ collectionEvalOp ( > if (((*StatusCode =3D=3D NULL) && (tmp =3D=3D NULL)) || > ((*StatusCode !=3D NULL) && ((**StatusCode < HTTP_STATUS_200_OK)= || > (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT)))) > { > + free (valid); > return tmp; > } >=20 > @@ -658,19 +660,15 @@ collectionEvalOp ( >=20 > cleanupPayload (members); > if (validCount =3D=3D 0) { > - free (valid); > - return NULL; > - } > - > - if (validCount =3D=3D 1) { > + ret =3D NULL; > + } else if (validCount =3D=3D 1) { > ret =3D valid[0]; > - free (valid); > - return ret; > } else { > ret =3D createCollection (payload->service, validCount, valid); > - free (valid); > - return ret; > } > + > + free (valid); > + return ret; > } >=20 > static redfishPayload * > -- > 2.20.1.windows.1