[PATCH v2 3/5] bootconfig: init: Fix memblock leak in setup_boot_config()

From: Masami Hiramatsu
Date: Tue Sep 14 2021 - 20:53:52 EST


Free unused memblock in a error case to fix memblock leak
in setup_boot_config().

Fixes: 7684b8582c24 ("bootconfig: Load boot config from the tail of initrd")
Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
init/main.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/init/main.c b/init/main.c
index 0b054fff8e92..4f059fde1df0 100644
--- a/init/main.c
+++ b/init/main.c
@@ -459,6 +459,7 @@ static void __init setup_boot_config(void)
else
pr_err("Failed to parse bootconfig: %s at %d.\n",
msg, pos);
+ memblock_free_ptr(copy, size + 1);
} else {
pr_info("Load bootconfig: %d bytes %d nodes\n", size, ret);
/* keys starting with "kernel." are passed via cmdline */