From nobody Sun Feb 8 12:42:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34D48C7EE23 for ; Tue, 30 May 2023 17:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233001AbjE3RWB (ORCPT ); Tue, 30 May 2023 13:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232657AbjE3RVi (ORCPT ); Tue, 30 May 2023 13:21:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E007F1 for ; Tue, 30 May 2023 10:21:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CEF006312A for ; Tue, 30 May 2023 17:21:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD3D7C433A7; Tue, 30 May 2023 17:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685467295; bh=d0V+rEHElAyacw8AbdTR1mJCInv/LtANWszfGeTQmgw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F8yDNQfTKA9nvMlc46CPI5hnKobBApcx8UpbyQ1/1Jd06THr0c1Yrc29KuHgNJONw L92oBaxPY9PsXAmIEgotQuKIHrBkiBC5GVST6kWNDK0uY+8YBWNgPibY1j4B43ldNH 562+wEDDcglgp32ZVVEowehtdTQbu8a8m+AzjLqnok5n0PNYOhfgNJfJFTbsJVEYk4 QiWITQu8W4BiqW6AzlDvZkF4NvH7PLwWEkcDs4w0GFg2PXNyB24+4KOb8AAWss5c+W 8FlrJpL2uKKklAZ58mASkOL3Kecc7GquZ+e9++L4rvpc0NfyWRlNGehVlJUYSokNeI QzUtIam/mbfug== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes Subject: [PATCH 09/22] objtool: Don't free memory in elf_close() Date: Tue, 30 May 2023 10:21:01 -0700 Message-Id: <74bdb3058b8f029db8d5b3b5175f2a200804196d.1685464332.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's not necessary, objtool's about to exit anyway. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 8d491b2d123e..8d53f18a9502 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -1350,30 +1350,14 @@ int elf_write(struct elf *elf) =20 void elf_close(struct elf *elf) { - struct section *sec, *tmpsec; - struct symbol *sym, *tmpsym; - struct reloc *reloc, *tmpreloc; - if (elf->elf) elf_end(elf->elf); =20 if (elf->fd > 0) close(elf->fd); =20 - list_for_each_entry_safe(sec, tmpsec, &elf->sections, list) { - list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) { - list_del(&sym->list); - hash_del(&sym->hash); - } - list_for_each_entry_safe(reloc, tmpreloc, &sec->reloc_list, list) { - list_del(&reloc->list); - hash_del(&reloc->hash); - } - list_del(&sec->list); - free(sec->reloc_data); - } - - free(elf->symbol_data); - free(elf->section_data); - free(elf); + /* + * NOTE: All remaining allocations are leaked on purpose. Objtool is + * about to exit anyway. + */ } --=20 2.40.1