From mboxrd@z Thu Jan 1 00:00:00 1970 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=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 82063C4332F for ; Wed, 15 Sep 2021 00:53:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6368D61244 for ; Wed, 15 Sep 2021 00:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232988AbhIOAyx (ORCPT ); Tue, 14 Sep 2021 20:54:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:41430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232064AbhIOAyv (ORCPT ); Tue, 14 Sep 2021 20:54:51 -0400 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); }