]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lib/bootconfig: drop redundant memset of xbc_nodes
authorJosh Law <objecting@objecting.org>
Wed, 18 Mar 2026 15:59:11 +0000 (15:59 +0000)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 18 Mar 2026 23:43:43 +0000 (08:43 +0900)
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>
lib/bootconfig.c

index c02b11a1b50192d359ea1f45d5034d5ac52ce108..1b4900053abee8d3e911f2d0e753a4bd6360c7c0 100644 (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)