lib/bootconfig: drop redundant memset of xbc_nodes

memblock_alloc() already returns zeroed memory, so the explicit memset
in xbc_init() is redundant. Switch the userspace xbc_alloc_mem() from
malloc() to calloc() so both paths return zeroed memory, and remove
the separate memset call.

Link: https://lore.kernel.org/all/20260318155919.78168-6-objecting@objecting.org/

Signed-off-by: Josh Law <objecting@objecting.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
This commit is contained in:
Josh Law
2026-03-18 15:59:11 +00:00
committed by Masami Hiramatsu (Google)
parent ae9bf4d383
commit 73a9f74b86

View File

@@ -71,7 +71,7 @@ static inline void __init xbc_free_mem(void *addr, size_t size, bool early)
static inline void *xbc_alloc_mem(size_t size)
{
return malloc(size);
return calloc(1, size);
}
static inline void xbc_free_mem(void *addr, size_t size, bool early)
@@ -983,7 +983,6 @@ int __init xbc_init(const char *data, size_t size, const char **emsg, int *epos)
_xbc_exit(true);
return -ENOMEM;
}
memset(xbc_nodes, 0, sizeof(struct xbc_node) * XBC_NODE_MAX);
ret = xbc_parse_tree();
if (!ret)