From patchwork Thu Sep 25 17:47:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 417 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822508; bh=V79wO1onhJ/wviRSg8I97qOuoi5LWjoXOlvzs8VlmsQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YE+yq2f1FbsuCieNBjFOj3/ue6JVkkATKJy7jO3xcGgC0PIwkQubJKS05OEXJvJ4W DLl6jFT+/O6pPD5syjlgAhLdB6fPyWgUv9S1s4iaU6UNW7ozhNfY9X/ro4sRzTOGOK V35c78cpJ3MYzrEoGllHVlk9732TxUJK1GVZggk32e3WI7o/hYooU97zg4xOt6OeaF u/pEwHkvv1qVV8qQwe2iesSYQ/bJ+f5zXUtLFBnQPcfAFxK9XSPyMqmbLszniQFHIw CbXGL4yIkLWOnACpbWjDUqF6W/XrfyJO4IAMo4chsvD0CNVX9Nhx880koKgpkED+Gs mbgHOZ6KrlxJQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9263167DA2 for ; Thu, 25 Sep 2025 11:48:28 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id A2VXQSDwmHZr for ; Thu, 25 Sep 2025 11:48:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822508; bh=V79wO1onhJ/wviRSg8I97qOuoi5LWjoXOlvzs8VlmsQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YE+yq2f1FbsuCieNBjFOj3/ue6JVkkATKJy7jO3xcGgC0PIwkQubJKS05OEXJvJ4W DLl6jFT+/O6pPD5syjlgAhLdB6fPyWgUv9S1s4iaU6UNW7ozhNfY9X/ro4sRzTOGOK V35c78cpJ3MYzrEoGllHVlk9732TxUJK1GVZggk32e3WI7o/hYooU97zg4xOt6OeaF u/pEwHkvv1qVV8qQwe2iesSYQ/bJ+f5zXUtLFBnQPcfAFxK9XSPyMqmbLszniQFHIw CbXGL4yIkLWOnACpbWjDUqF6W/XrfyJO4IAMo4chsvD0CNVX9Nhx880koKgpkED+Gs mbgHOZ6KrlxJQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7CCE867D93 for ; Thu, 25 Sep 2025 11:48:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822507; bh=yANkU3Qm+BMx+aB+0cPL/8er4vJxn3QZQdjwjRPfAKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=crBZWKnTjDWePaavPL6Zqc2KRqrAppgz9Q59EFqDQisE0e7orbqVKya3t8YyzEdb6 ULVWz41n4LXqSVPGYAnUGTGw9RTXr4aSGagPAMqv5oLDue96a6jBly0s+XjCHbNCb0 CY23GHy3l1aoCZz3FJapN/2vcOscEHPX9QIjxq8GCRWS5DuBIW/jOq1JQ55ta1kgZ8 l7wJuHoBwY1WQY4rQoHLREqzFnMER0UOil+RUfXUSyvrCR8ygz+ZUVjKERk5PQ2JDb 71RHCJVjvl+6Pf5xJpRkyf4MdVkg1/cSAecuqQLE83PhxqDO7UZtLH0ETJ4o76GHJy yFRyZSH8/2gzQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21A1967D29; Thu, 25 Sep 2025 11:48:27 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id oY9gqxtYxdR9; Thu, 25 Sep 2025 11:48:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758822504; bh=B7JOnV+x5IJ8XrFA4wMvKIwOnAYlOuw2Mb/fXxH+t00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZMC3tnWE26xTioIgUcIiQ73XKOjlU6IzlsSUBaE5OvVjddi/nUuzC7rmvjiRkO/T2 K5/eBMHjLrsAI5B+lqqZT6xNwvBhkVx2Mkg0uT2wnfWs8CDquhtXp/Om03OQKeoMmr Wzyw/pQWQrlApJEMMUYKaqat+Tq7m4FOY0D/D0vcVK34M0kxs71dEmRX3RdTYQjruK I0lRQiAwUQfGNTLDXmnshW1bOgyrT8JHnlmXJ2cgrh7Qa9mJgYLTc4wFAy3Bb1+iVX /GT68fEvEl97ehgS/GON293onYCwOvGCbsr2+GYuL0H/c9bO/nFM+k1IuSUMaGhjGp 8tuQ+lajBL3ug== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 50A7E67CAC; Thu, 25 Sep 2025 11:48:24 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 25 Sep 2025 11:47:29 -0600 Message-ID: <20250925174753.3429102-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250925174753.3429102-1-sjg@u-boot.org> References: <20250925174753.3429102-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: T5SF4HERSDIPRACJLQMFFZMRVQG2TDAX X-Message-ID-Hash: T5SF4HERSDIPRACJLQMFFZMRVQG2TDAX X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Ilias Apalodimas X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/22] efi: Avoid a memory leak in efi_bind_block() on error path List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Free the memory used if an error occurs. Suggested-by: Ilias Apalodimas Signed-off-by: Simon Glass --- lib/efi_client/efi_app_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/efi_client/efi_app_init.c b/lib/efi_client/efi_app_init.c index b5421dc5a91..462c9db61e9 100644 --- a/lib/efi_client/efi_app_init.c +++ b/lib/efi_client/efi_app_init.c @@ -60,8 +60,10 @@ int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio, plat->handle = handle; plat->blkio = blkio; plat->device_path = malloc(device_path_len); - if (!plat->device_path) + if (!plat->device_path) { + free(plat); return log_msg_ret("path", -ENOMEM); + } memcpy(plat->device_path, device_path, device_path_len); snprintf(name, sizeof(name), "efi_media_%x",