All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Mike Rapoport <rppt@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Linux-MM <linux-mm@kvack.org>, Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH v2 4/5] bootconfig: Free copied bootconfig data after boot
Date: Wed, 15 Sep 2021 09:53:30 +0900	[thread overview]
Message-ID: <163166721027.510331.6820619440348067061.stgit@devnote2> (raw)
In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2>

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 <mhiramat@kernel.org>
---
 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();
 }
 


  parent reply	other threads:[~2021-09-15  0:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  0:52 [PATCH v2 0/5] bootconfig: Fixes to bootconfig memory management Masami Hiramatsu
2021-09-15  0:53 ` [PATCH v2 1/5] bootconfig: Fix to check the xbc_node is used before free it Masami Hiramatsu
2021-09-15  1:12   ` Linus Torvalds
2021-09-15  1:12     ` Linus Torvalds
2021-09-15  1:44     ` Masami Hiramatsu
2021-09-15  0:53 ` [PATCH v2 2/5] bootconfig: init: Fix memblock leak in xbc_make_cmdline() Masami Hiramatsu
2021-09-15  0:53 ` [PATCH v2 3/5] bootconfig: init: Fix memblock leak in setup_boot_config() Masami Hiramatsu
2021-09-15  0:53 ` Masami Hiramatsu [this message]
2021-09-15  1:13   ` [PATCH v2 4/5] bootconfig: Free copied bootconfig data after boot Linus Torvalds
2021-09-15  1:13     ` Linus Torvalds
2021-09-15  1:45     ` Masami Hiramatsu
2021-09-15  0:53 ` [PATCH v2 5/5] tools/bootconfig: Define memblock_free_ptr() to fix build error Masami Hiramatsu
2021-09-15  1:21   ` Linus Torvalds
2021-09-15  1:21     ` Linus Torvalds
2021-09-15  1:47     ` Masami Hiramatsu
2021-09-15  1:57       ` Linus Torvalds
2021-09-15  1:57         ` Linus Torvalds
2021-09-15  3:00         ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=163166721027.510331.6820619440348067061.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.