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 1/5] bootconfig: Fix to check the xbc_node is used before free it
Date: Wed, 15 Sep 2021 09:53:06 +0900 [thread overview]
Message-ID: <163166718582.510331.11732633028925882626.stgit@devnote2> (raw)
In-Reply-To: <163166717752.510331.12843735095061762373.stgit@devnote2>
Fix to check the xbc_node is used before calling memblock_free()
because passing NULL to phys_addr() will cause a panic.
This will happen if user doesn't pass any bootconfig to the
kernel, because kernel will call xbc_destroy_all() after
booting.
Fixes: 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
Changes in v2:
- Rebase on top of Linus tree.
---
lib/bootconfig.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 5ae248b29373..bee691ea8213 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -792,7 +792,8 @@ void __init xbc_destroy_all(void)
xbc_data = NULL;
xbc_data_size = 0;
xbc_node_num = 0;
- memblock_free_ptr(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX);
+ if (xbc_nodes)
+ memblock_free_ptr(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX);
xbc_nodes = NULL;
brace_index = 0;
}
next prev parent reply other threads:[~2021-09-15 0:53 UTC|newest]
Thread overview: 14+ 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 ` Masami Hiramatsu [this message]
2021-09-15 1:12 ` [PATCH v2 1/5] bootconfig: Fix to check the xbc_node is used before free it 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 ` [PATCH v2 4/5] bootconfig: Free copied bootconfig data after boot Masami Hiramatsu
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:47 ` Masami Hiramatsu
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=163166718582.510331.11732633028925882626.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox