From patchwork Wed Sep 15 00:53:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 12495211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4765FC433EF for ; Wed, 15 Sep 2021 00:53:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D8B8C61242 for ; Wed, 15 Sep 2021 00:53:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D8B8C61242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7978E940008; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 746E16B0074; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 635F2940008; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 551F96B0073 for ; Tue, 14 Sep 2021 20:53:34 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1410782499B9 for ; Wed, 15 Sep 2021 00:53:34 +0000 (UTC) X-FDA: 78587984748.06.208755D Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf09.hostedemail.com (Postfix) with ESMTP id C3D523000103 for ; Wed, 15 Sep 2021 00:53:33 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id C72D761165; Wed, 15 Sep 2021 00:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631667213; bh=z+Rz9mifdit69o+uIbSikKcuPTSNShUmHrawtlDV4WI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GDzsdNsTDeveoDIbcZEYLKzJtN/0PoJtqtdsyBL0M8chUFYMumXnG5+nM2QgwDAhX uuVRNmUA/SbTPOOrDx1175Hx9PRJDNCzHrC/gvRNX8lvbs/ct0VCwbSS63EIybHUju TJGz5l79xcqMg8a2uTf8O+4hYqd8vTT5vQwPmXGuuQygQCdFuv39/W0q1wjkKv0a5o ojmJ6IJYf5u6gQrvUUb4aCbvh7Q7StuRlw5rk22DUoAiO44ruDzlkKKB+lnIVjFlhu Wn8KUcc0Cbh0DzymItHLsKaUiXdP6E1/THe3KynYMzzYBogMTtxgrh/XHPcOLilUe0 rpqFVbaz1REuw== From: Masami Hiramatsu To: Steven Rostedt Cc: Linus Torvalds , Mike Rapoport , Andrew Morton , LKML , Ingo Molnar , Masami Hiramatsu , Linux-MM , Vlastimil Babka Subject: [PATCH v2 4/5] bootconfig: Free copied bootconfig data after boot Date: Wed, 15 Sep 2021 09:53:30 +0900 Message-Id: <163166721027.510331.6820619440348067061.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2> References: <163166717752.510331.12843735095061762373.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C3D523000103 X-Stat-Signature: ea7636fc7d3c45rpzsptixadh4yx5u9f Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GDzsdNsT; spf=pass (imf09.hostedemail.com: domain of mhiramat@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=mhiramat@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1631667213-571632 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Free copied bootconfig data after booting kernel because that data will not be used anymore. commit 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed") freed the bootconfig xbc_node array after booting kernel, but forgot to free the bootconfig data itself. This fixes that to free the bootconfig data too. Fixes: 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed") Signed-off-by: Masami Hiramatsu --- Changes in v2: - Split memblock leak fix because it fixes another commit. - Use memblock_free_ptr() --- init/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init/main.c b/init/main.c index 4f059fde1df0..0148152652e9 100644 --- a/init/main.c +++ b/init/main.c @@ -319,6 +319,8 @@ static void * __init get_boot_config_from_initrd(u32 *_size, u32 *_csum) #ifdef CONFIG_BOOT_CONFIG static char xbc_namebuf[XBC_KEYLEN_MAX] __initdata; +static void *init_xbc_data_copy __initdata; +static phys_addr_t init_xbc_data_size __initdata; #define rest(dst, end) ((end) > (dst) ? (end) - (dst) : 0) @@ -466,12 +468,17 @@ static void __init setup_boot_config(void) extra_command_line = xbc_make_cmdline("kernel"); /* Also, "init." keys are init arguments */ extra_init_args = xbc_make_cmdline("init"); + init_xbc_data_copy = copy; + init_xbc_data_size = size + 1; } return; } static void __init exit_boot_config(void) { + if (!init_xbc_data_copy) + return; + memblock_free_ptr(init_xbc_data_copy, init_xbc_data_size); xbc_destroy_all(); }