On Wed, 9 Sep 2026 01:57:11 +0900
Sang-Heon Jeon <[email protected]> wrote:
> Since commit 87ce9e83ab8b ("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.
Good catch!
Let me pick this to bootconfig/for-next.
Thank you!
>
> Signed-off-by: Sang-Heon Jeon <[email protected]>
> ---
> include/linux/bootconfig.h | 7 +------
> lib/bootconfig.c | 22 +++++++++-------------
> 2 files changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h
> index deda507500da..fdc15b6f4d1b 100644
> --- a/include/linux/bootconfig.h
> +++ b/include/linux/bootconfig.h
> @@ -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
> diff --git a/lib/bootconfig.c b/lib/bootconfig.c
> index 89c88e359179..aba11caf6903 100644
> --- a/lib/bootconfig.c
> +++ b/lib/bootconfig.c
> @@ -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;
> }
>
> base-commit: 85595d3f964825c833fd2597521fcef67c3071de
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <[email protected]>