From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 95175740039 for ; Wed, 11 Jun 2025 04:03:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=23MziQ5qJxA9O25n2Wk9kyOX0Cxb5vwH1D4E1s4FgWo=; c=relaxed/simple; d=groups.io; h=From:To:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240830; t=1749614595; v=1; x=1749873793; b=CPRmcwGUUcDjh6V3wxui4WH21lTk5lP5BKcYzAXCNKLKgR1cqeM8xJxejjqj5t9QaqPrTVLR 91ZLEhin22vPmhBSPdc3/A2zJGutVaQncnspfnjLBrxiQNThyWKe1mCf5KoPZwj2cYm2OcLAWZB IITIQ48GqTHC51+xI0sjsjGjdUrsmYiAarruktYh9Y3DMaYCoL5yqJI0dQKMXnIEQ7AsO1RCFgG vUmNc/uj9u5nFlDQVXNMbEd/wxtglozmUHCh7VvS42dqDGPCFYAf1VIsNjJz9yNA+YsWDaMGAuW hHIEWDpP+uosx8T5VY7SanYSt5/yQWOoig6Jru4Y8fgpA== X-Received: by 127.0.0.2 with SMTP id lzMEYY7687511xKBM6x33LqO; Tue, 10 Jun 2025 21:03:13 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.2639.1749614591908326148 for ; Tue, 10 Jun 2025 21:03:12 -0700 X-Received: from loongson.cn (unknown [10.2.9.245]) by gateway (Coremail) with SMTP id _____8Bx22r8_0hoyl4TAQ--.12702S3; Wed, 11 Jun 2025 12:03:08 +0800 (CST) X-Received: from code-server.gen (unknown [10.2.9.245]) by front1 (Coremail) with SMTP id qMiowMAxDcX7_0ho5G0VAQ--.61653S4; Wed, 11 Jun 2025 12:03:08 +0800 (CST) From: "Dongyan Qian" To: devel@edk2.groups.io Subject: [edk2-devel] [PATCH 3/4] PrmPkg/DxePrmContextBufferLib: Free handle buffers after LocateHandleBuffer Date: Wed, 11 Jun 2025 12:03:05 +0800 Message-Id: <20250611040306.199659-3-qiandongyan@loongson.cn> In-Reply-To: <20250611040306.199659-1-qiandongyan@loongson.cn> References: <20250611040306.199659-1-qiandongyan@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: qMiowMAxDcX7_0ho5G0VAQ--.61653S4 X-CM-SenderInfo: htld0v5rqj5t3q6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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 Resent-Date: Tue, 10 Jun 2025 21:03:12 -0700 Resent-From: qiandongyan@loongson.cn Reply-To: devel@edk2.groups.io,qiandongyan@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: t05c1f7MnNIGmVMVIbFYwY98x7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=CPRmcwGU; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Fix memory leaks by adding missing FreePool calls: cleanup HandleBuffer in GetModuleContextBuffers. REF: https://uefi.org/sites/default/files/resources/UEFI_Spec_Final_2.11.pdf Chapter 7.3.15: "Services - Boot Services.LocateHandleBuffer": It is the caller's responsibility to call the Boot Service.FreePool when the caller no longer requires the contents of Buffer. Signed-off-by: Dongyan Qian --- .../DxePrmContextBufferLib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c b/PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c index a6ad141556..357d2c0438 100644 --- a/PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c +++ b/PrmPkg/Library/DxePrmContextBufferLib/DxePrmContextBufferLib.c @@ -127,13 +127,15 @@ GetModuleContextBuffers ( )); *PrmModuleContextBuffers = &PrmConfigProtocol->ModuleContextBuffers; - return EFI_SUCCESS; + Status = EFI_SUCCESS; + goto Exit; } } else { Status = FindContextBufferInModuleBuffers (Guid, &PrmConfigProtocol->ModuleContextBuffers, &PrmContextBuffer); if (!EFI_ERROR (Status)) { *PrmModuleContextBuffers = &PrmConfigProtocol->ModuleContextBuffers; - return EFI_SUCCESS; + Status = EFI_SUCCESS; + goto Exit; } } } @@ -147,7 +149,14 @@ GetModuleContextBuffers ( Guid )); - return EFI_NOT_FOUND; + Status = EFI_NOT_FOUND; + +Exit: + if (HandleBuffer != NULL) { + gBS->FreePool (HandleBuffer); + } + + return Status; } /** -- 2.49.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#121414): https://edk2.groups.io/g/devel/message/121414 Mute This Topic: https://groups.io/mt/113583366/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-