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 9F21E7803CC for ; Sun, 10 Mar 2024 10:42:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=7tJ4jFNqn0hD/e5yrcIYqmIlWTpUIyuxee78LEoI/M0=; 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=1710067319; v=1; b=TcbsC1cMqT14q0ChjsTs8VQ3tYOWHQ5O50oi2N1iGfYrZbi4eYd3LsGg4gRNHM9JaemP46dJ I9bWSpZhh7IrY3DR682YZslDQhnapqXWUBHofhnGTqqda1zSFc13veRy7DYy861/YqV/H3PRlwT ijXQAhLr6e0yVCvvYyoUUH7m5rHVMKH8u7EUIFIURIilIsXer+8rfk1b23yJOY5xm0NjEIoq9Sx w7kfbEY3T7cse9xE9bqe/eTY4HphUSGmCE1wMBb9+axfdwr8cuZk8hPpWX+f6g1Pn4w8OEA6uFe jsSjHZiAGkjz85QPqfvU/nk6MCkQBvRL7eOXBGso/mQNw== X-Received: by 127.0.0.2 with SMTP id VQCQYY7687511xRZiJ3VRssg; Sun, 10 Mar 2024 03:41:59 -0700 X-Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by mx.groups.io with SMTP id smtpd.web11.31618.1710067318337634286 for ; Sun, 10 Mar 2024 03:41:58 -0700 X-Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2d204e102a9so43954931fa.0 for ; Sun, 10 Mar 2024 03:41:58 -0700 (PDT) X-Gm-Message-State: Kg3ymnzwDMlIxPB2xyG1UsDGx7686176AA= X-Google-Smtp-Source: AGHT+IHCiyonJrvBfcwYI5TcZQ10WMBjlWgadXSeNalO+Us7eFxZLEJVXtTchY/paVLTc52Tk5lQ0A== X-Received: by 2002:a05:651c:384:b0:2d2:dd4b:4beb with SMTP id e4-20020a05651c038400b002d2dd4b4bebmr1741995ljp.1.1710067315907; Sun, 10 Mar 2024 03:41:55 -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.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 10 Mar 2024 03:41:55 -0700 (PDT) From: "Mike Maslenkin" To: devel@edk2.groups.io Cc: Mike Maslenkin , Abner Chang , Igor Kulchytskyy , Nickle Wang Subject: [edk2-devel] [PATCH 1/4][edk2-redfish-client] RedfishClientPkg: fix memory leak Date: Sun, 10 Mar 2024 03:41:58 -0700 Message-Id: <20240310104151.41355-2-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=TcbsC1cM; 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 This patch fixes leak of EFI_REDFISH_COMPUTERSYSTEMCOLLECTION instance on error path. Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nickle Wang Signed-off-by: Mike Maslenkin --- .../ComputerSystemCollectionDxe.c | 12 +++++++++--- .../MemoryCollectionDxe/MemoryCollectionDxe.c | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/Computer= SystemCollectionDxe.c b/RedfishClientPkg/Features/ComputerSystemCollectionD= xe/ComputerSystemCollectionDxe.c index 55a6d07dbf2e..3deefa824629 100644 --- a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC= ollectionDxe.c +++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC= ollectionDxe.c @@ -174,11 +174,13 @@ HandleCollectionResource ( CollectionCs =3D Collection->ComputerSystemCollection;=0D =0D if (*CollectionCs->Membersodata_count =3D=3D 0) {=0D - return EFI_NOT_FOUND;=0D + Status =3D EFI_NOT_FOUND;=0D + goto ON_RELEASE;=0D }=0D =0D if (IsLinkEmpty (&CollectionCs->Members)) {=0D - return EFI_NOT_FOUND;=0D + Status =3D EFI_NOT_FOUND;=0D + goto ON_RELEASE;=0D }=0D =0D List =3D GetFirstLink (&CollectionCs->Members);=0D @@ -206,12 +208,16 @@ HandleCollectionResource ( List =3D GetNextLink (&CollectionCs->Members, List);=0D }=0D =0D + Status =3D EFI_SUCCESS;=0D +=0D +ON_RELEASE:=0D +=0D //=0D // Release resource.=0D //=0D Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Collection);=0D =0D - return EFI_SUCCESS;=0D + return Status;=0D }=0D =0D EFI_STATUS=0D diff --git a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollection= Dxe.c b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c index d963fb52ad37..38f28f902715 100644 --- a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c @@ -165,11 +165,13 @@ HandleCollectionResource ( CollectionCs =3D Collection->MemoryCollection;=0D =0D if (*CollectionCs->Membersodata_count =3D=3D 0) {=0D - return EFI_NOT_FOUND;=0D + Status =3D EFI_NOT_FOUND;=0D + goto ON_RELEASE;=0D }=0D =0D if (IsLinkEmpty (&CollectionCs->Members)) {=0D - return EFI_NOT_FOUND;=0D + Status =3D EFI_NOT_FOUND;=0D + goto ON_RELEASE;=0D }=0D =0D List =3D GetFirstLink (&CollectionCs->Members);=0D @@ -197,12 +199,15 @@ HandleCollectionResource ( List =3D GetNextLink (&CollectionCs->Members, List);=0D }=0D =0D + Status =3D EFI_SUCCESS;=0D +=0D +ON_RELEASE:=0D //=0D // Release resource.=0D //=0D Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Collection);=0D =0D - return EFI_SUCCESS;=0D + return Status;=0D }=0D =0D EFI_STATUS=0D --=20 2.32.0 (Apple Git-132) -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116565): https://edk2.groups.io/g/devel/message/116565 Mute This Topic: https://groups.io/mt/104841892/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-