bootconfig: merge _xbc_exit() into xbc_exit()

Since commit 87ce9e83ab ("memblock, treewide: make memblock_free()
handle late freeing"), both branches of xbc_free_mem() call
memblock_free(), and the early argument has no effect.

memblock_free() also does nothing if addr is NULL, so the check
before the call is redundant.

So remove the argument and the NULL check, and merge _xbc_exit() into
xbc_exit().

No functional change.

Link: https://lore.kernel.org/all/20260908165712.1703439-1-ekffu200098@gmail.com/

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
This commit is contained in:
Sang-Heon Jeon 2026-09-11 23:30:20 +09:00 committed by Masami Hiramatsu (Google)
parent 7812d6dab0
commit 2878d76d86
2 changed files with 10 additions and 19 deletions

View File

@ -291,12 +291,7 @@ int __init xbc_init(const char *buf, size_t size, const char **emsg, int *epos);
int __init xbc_get_info(int *node_size, size_t *data_size);
/* XBC cleanup data structures */
void __init _xbc_exit(bool early);
static __always_inline void xbc_exit(void)
{
_xbc_exit(false);
}
void __init xbc_exit(void);
/* XBC embedded bootconfig data in kernel */
#ifdef CONFIG_BOOT_CONFIG_EMBED

View File

@ -187,12 +187,9 @@ static inline void * __init xbc_alloc_mem(size_t size)
return memblock_alloc(size, SMP_CACHE_BYTES);
}
static inline void __init xbc_free_mem(void *addr, size_t size, bool early)
static inline void __init xbc_free_mem(void *addr, size_t size)
{
if (early)
memblock_free(addr, size);
else if (addr)
memblock_free(addr, size);
memblock_free(addr, size);
}
#else /* !__KERNEL__ */
@ -202,7 +199,7 @@ static inline void *xbc_alloc_mem(size_t size)
return calloc(1, size);
}
static inline void xbc_free_mem(void *addr, size_t size, bool early)
static inline void xbc_free_mem(void *addr, size_t size)
{
free(addr);
}
@ -1123,20 +1120,19 @@ static int __init xbc_parse_tree(void)
}
/**
* _xbc_exit() - Clean up all parsed bootconfig
* @early: Set true if this is called before budy system is initialized.
* xbc_exit() - Clean up all parsed bootconfig
*
* This clears all data structures of parsed bootconfig on memory.
* If you need to reuse xbc_init() with new boot config, you can
* use this.
*/
void __init _xbc_exit(bool early)
void __init xbc_exit(void)
{
xbc_free_mem(xbc_data, xbc_data_size, early);
xbc_free_mem(xbc_data, xbc_data_size);
xbc_data = NULL;
xbc_data_size = 0;
xbc_node_num = 0;
xbc_free_mem(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX, early);
xbc_free_mem(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX);
xbc_nodes = NULL;
brace_index = 0;
}
@ -1189,7 +1185,7 @@ int __init xbc_init(const char *data, size_t size, const char **emsg, int *epos)
if (!xbc_nodes) {
if (emsg)
*emsg = "Failed to allocate bootconfig nodes";
_xbc_exit(true);
xbc_exit();
return -ENOMEM;
}
@ -1202,7 +1198,7 @@ int __init xbc_init(const char *data, size_t size, const char **emsg, int *epos)
*epos = xbc_err_pos;
if (emsg)
*emsg = xbc_err_msg;
_xbc_exit(true);
xbc_exit();
} else {
ret = xbc_node_num;
}