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 4169394162B for ; Tue, 30 Jan 2024 11:15:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Vo31Kx1SZ3PmeitAHSyPoxeQstN5wDVSTEYZ/1OB31g=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706613326; v=1; b=am5DrKkhng/VJvPPHhWpkjVTgCTBSPA09o7lD1Rx22id8v4qlUEX84KSJ4x0C9phudE++z/s ikJfuMpY9o3dZqiBztmRQ9QnHH+QQqdqjz1OdETe+n3WoJVPoRjV/lkD1PwLcAqRE0AyaR8fH7B /bC0yFq1kUo3lsEUnTnZaEcs= X-Received: by 127.0.0.2 with SMTP id 9YXAYY7687511xzDGd94ss4s; Tue, 30 Jan 2024 03:15:26 -0800 X-Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by mx.groups.io with SMTP id smtpd.web10.15973.1706613326010179663 for ; Tue, 30 Jan 2024 03:15:26 -0800 X-Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-5ffdf06e009so37646577b3.3 for ; Tue, 30 Jan 2024 03:15:25 -0800 (PST) X-Gm-Message-State: X0ZeyTAjcHVO3J8FEj3EgVmnx7686176AA= X-Google-Smtp-Source: AGHT+IGFcW20KVNY6s24Wbgg6aenkM/a1dxy0twbP10aRWbxZ9h+caKxK38nSQ31VrIjZa17uSy58qgos3mx4vCKylM= X-Received: by 2002:a81:e202:0:b0:5ff:9449:abfe with SMTP id p2-20020a81e202000000b005ff9449abfemr5042360ywl.36.1706613324456; Tue, 30 Jan 2024 03:15:24 -0800 (PST) MIME-Version: 1.0 References: <20240127000128.67202-1-mike.maslenkin@gmail.com> <20240127000128.67202-3-mike.maslenkin@gmail.com> In-Reply-To: From: "Mike Maslenkin" Date: Tue, 30 Jan 2024 14:14:48 +0300 Message-ID: Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH 2/2] RedfishClientPkg: fix memory leak in ConverterLib To: "Chang, Abner" Cc: "devel@edk2.groups.io" , "nicklew@nvidia.com" , "igork@ami.com" 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,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=am5DrKkh; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Abner, I created PR containing patch 2/2 with your R-b set. https://github.com/DMTF/Redfish-Schema-C-Struct-Generator/pull/5 Please review and commit. Thank you! Regards, Mike. On Mon, Jan 29, 2024 at 5:41=E2=80=AFAM Chang, Abner = wrote: > > [AMD Official Use Only - General] > > Reviewed-by: Abner Chang > > Would you like to create a PR on below repo https://github.com/DMTF/Redfi= sh-Schema-C-Struct-Generator for the 2/2 patch? As we should fix the issue = on DMTF Github as well. RedfishCsCommon.c is here, https://github.com/DMTF/= Redfish-Schema-C-Struct-Generator/tree/main/src. I can also help to sync up= the fix if you are ok with it. > > Thanks > Abner > > > > -----Original Message----- > > From: Mike Maslenkin > > Sent: Saturday, January 27, 2024 8:01 AM > > To: devel@edk2.groups.io > > Cc: Chang, Abner ; nicklew@nvidia.com; > > igork@ami.com; Mike Maslenkin > > Subject: [edk2-redfish-client][PATCH 2/2] RedfishClientPkg: fix memory = leak in > > ConverterLib > > > > Caution: This message originated from an External Source. Use proper ca= ution > > when opening attachments, clicking links, or responding. > > > > > > The memory returned by json_dumps() must be freed. > > > > Signed-off-by: Mike Maslenkin > > Cc: Abner Chang > > Cc: Nickle Wang > > Cc: Igor Kulchytskyy > > --- > > RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c > > b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c > > index 126200dd019c..250ef75e40de 100644 > > --- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c > > +++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c > > @@ -379,15 +379,19 @@ CreateCsJsonByNode ( > > if (TempChar !=3D NULL) { > > > > Status =3D allocateRecordCsMemory (Cs, sizeof > > (RedfishCS_Type_JSON_Data), (void **)&CsTypeJson); > > > > if (Status !=3D RedfishCS_status_success) { > > > > + free (TempChar); > > > > return Status; > > > > } > > > > > > > > Status =3D allocateRecordCsMemory (Cs, (RedfishCS_int)strlen (Temp= Char) + > > 1, (void **)&DumpStr); > > > > if (Status !=3D RedfishCS_status_success) { > > > > + free (TempChar); > > > > return Status; > > > > } > > > > > > > > strncpy (DumpStr, TempChar, strlen (TempChar) + 1); > > > > + free (TempChar); > > > > + > > > > InitializeLinkHead (&CsTypeJson->Header.LinkEntry); > > > > CsTypeJson->Header.ResourceType =3D RedfishCS_Type_JSON; > > > > CsTypeJson->Header.ThisUri =3D ParentUri; > > > > @@ -1506,9 +1510,10 @@ RemoveUnchangeableProperties ( > > Status =3D RedfishCS_status_insufficient_memory; > > > > } else { > > > > memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1); > > > > - free (TempChar); > > > > Status =3D RedfishCS_status_success; > > > > } > > > > + > > > > + free (TempChar); > > > > } else { > > > > Status =3D RedfishCS_status_unknown_error; > > > > } > > > > -- > > 2.32.0 (Apple Git-132) > -=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 (#114770): https://edk2.groups.io/g/devel/message/114770 Mute This Topic: https://groups.io/mt/103988340/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-