diff mbox series

[v2,2/5] bootconfig: init: Fix memblock leak in xbc_make_cmdline()

Message ID 163166719378.510331.1159980452908668023.stgit@devnote2 (mailing list archive)
State New
Headers show
Series bootconfig: Fixes to bootconfig memory management | expand

Commit Message

Masami Hiramatsu (Google) Sept. 15, 2021, 12:53 a.m. UTC
Free unused memblock in a error case to fix memblock leak
in xbc_make_cmdline().

Fixes: 51887d03aca1 ("bootconfig: init: Allow admin to use bootconfig for kernel command line")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 init/main.c |    1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/init/main.c b/init/main.c
index 3f7216934441..0b054fff8e92 100644
--- a/init/main.c
+++ b/init/main.c
@@ -382,6 +382,7 @@  static char * __init xbc_make_cmdline(const char *key)
 	ret = xbc_snprint_cmdline(new_cmdline, len + 1, root);
 	if (ret < 0 || ret > len) {
 		pr_err("Failed to print extra kernel cmdline.\n");
+		memblock_free_ptr(new_cmdline, len + 1);
 		return NULL;
 	}