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 91395D80047 for ; Sun, 10 Mar 2024 10:42:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=NwNkY/jHY4jZijII/mZ1sdrPDn0DH49Y68uWeYQRtso=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1710067321; v=1; b=zJJdTNterk8PADBcdSHRYT0rg0fO+USaTo178BIUedH9raw9fU0L5jvOYmyvlHun4DFlCATW DzAO2QH85R5H12+gHi5cNQXsgDTC6nEyHojra/mOlwZJnIDekkB7clxwTU+fI1PeySBvgHZcuZe CI5nfG82IkHbTLAJ/j4gw/1i/EUX2Bxw0i1DAoee9Z+GNvHkbPcwyeOZU7CLVn9SThyBpsOKFX4 +DljFsaGtdIcQev75e15DgclvmbkAU0RyAP/GGqjqPDePi9gPdeKpC5yvanVetxzBZ/qEabX92v 1U1ZLKErZerdKZ4H9yC5L4eeIcW83QMYT1klwOpOilfAQ== X-Received: by 127.0.0.2 with SMTP id YaxuYY7687511xWxIaeEb6Uz; Sun, 10 Mar 2024 03:42:01 -0700 X-Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by mx.groups.io with SMTP id smtpd.web11.31622.1710067319359576161 for ; Sun, 10 Mar 2024 03:41:59 -0700 X-Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d28387db09so29702591fa.0 for ; Sun, 10 Mar 2024 03:41:59 -0700 (PDT) X-Gm-Message-State: BVrJcgs5RFqv503TrJnbtVZax7686176AA= X-Google-Smtp-Source: AGHT+IEpgaaA3tq1gW6tGbooMb1rmrjEjXSE87L6CYh+MsoWo6gkw+SE0D1ADqLsvOQWk3ZUA/Luhg== X-Received: by 2002:a2e:a98c:0:b0:2d4:3c32:816f with SMTP id x12-20020a2ea98c000000b002d43c32816fmr81880ljq.2.1710067317480; Sun, 10 Mar 2024 03:41:57 -0700 (PDT) X-Received: from localhost.localdomain ([195.91.209.163]) by smtp.gmail.com with ESMTPSA id z8-20020a2e9648000000b002d3202b2b90sm614238ljh.87.2024.03.10.03.41.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 10 Mar 2024 03:41:57 -0700 (PDT) From: "Mike Maslenkin" 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 Date: Sun, 10 Mar 2024 03:41:59 -0700 Message-Id: <20240310104151.41355-4-mike.maslenkin@gmail.com> In-Reply-To: <20240310104151.41355-1-mike.maslenkin@gmail.com> References: <20240310104151.41355-1-mike.maslenkin@gmail.com> MIME-Version: 1.0 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-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=zJJdTNte; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) The structure instance retunred by ToStructure() must be deallocated properly. 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(-) diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Comput= erSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/= ComputerSystemCommon.c index df22a1c90c46..4795e4d6c6eb 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste= mCommon.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste= mCommon.c @@ -263,7 +263,7 @@ ProvisioningComputerSystemProperties ( );=0D if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status= ));=0D - return Status;=0D + goto ON_RELEASE;=0D }=0D =0D ComputerSystemCs =3D ComputerSystem->ComputerSystem;=0D @@ -365,7 +365,7 @@ ProvisioningComputerSystemProperties ( );=0D if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status));= =0D - return Status;=0D + goto ON_RELEASE;=0D }=0D =0D if (PropertyChanged) {=0D @@ -374,10 +374,14 @@ ProvisioningComputerSystemProperties ( if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable proper= ties from ResultJson.\n", __func__));=0D *ResultJson =3D NULL;=0D - return Status;=0D + goto ON_RELEASE;=0D }=0D }=0D =0D + Status =3D EFI_SUCCESS;=0D +=0D +ON_RELEASE:=0D +=0D //=0D // Release resource.=0D //=0D @@ -393,10 +397,17 @@ ProvisioningComputerSystemProperties ( DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, Array= Size);=0D }=0D =0D - JsonStructProtocol->DestoryStructure (=0D - JsonStructProtocol,=0D - (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEm= pty=0D - );=0D + if (ComputerSystemEmpty !=3D NULL) {=0D + JsonStructProtocol->DestoryStructure (=0D + JsonStructProtocol,=0D + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem= Empty=0D + );=0D + }=0D +=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND);=0D }=0D =0D diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Compute= rSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Co= mputerSystemCommon.c index c383cad59029..2d257e01da2b 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystem= Common.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystem= Common.c @@ -793,7 +793,7 @@ ProvisioningComputerSystemProperties ( );=0D if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a: ToStructure failure: %r\n", __func__, Status= ));=0D - return Status;=0D + goto ON_RELEASE;=0D }=0D =0D ComputerSystemCs =3D ComputerSystem->ComputerSystem;=0D @@ -1235,7 +1235,7 @@ ProvisioningComputerSystemProperties ( );=0D if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a: ToJson() failed: %r\n", __func__, Status));= =0D - return Status;=0D + goto ON_RELEASE;=0D }=0D =0D if (PropertyChanged) {=0D @@ -1244,10 +1244,14 @@ ProvisioningComputerSystemProperties ( if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a: Fail to remove Redfish unchangeable proper= ties from ResultJson.\n", __func__));=0D *ResultJson =3D NULL;=0D - return Status;=0D + goto ON_RELEASE;=0D }=0D }=0D =0D + Status =3D EFI_SUCCESS;=0D +=0D +ON_RELEASE:=0D +=0D //=0D // Release resource.=0D //=0D @@ -1263,10 +1267,17 @@ ProvisioningComputerSystemProperties ( DestoryRedfishCharArray (ComputerSystemCsEmpty->Boot->BootOrder, Array= Size);=0D }=0D =0D - JsonStructProtocol->DestoryStructure (=0D - JsonStructProtocol,=0D - (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemEm= pty=0D - );=0D + if (ComputerSystemEmpty !=3D NULL) {=0D + JsonStructProtocol->DestoryStructure (=0D + JsonStructProtocol,=0D + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem= Empty=0D + );=0D + }=0D +=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D return (PropertyChanged ? EFI_SUCCESS : EFI_NOT_FOUND);=0D }=0D =0D --=20 2.32.0 (Apple Git-132) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116567): https://edk2.groups.io/g/devel/message/116567 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] -=-=-=-=-=-=-=-=-=-=-=-