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.

Signed-off-by: Josh Law <[email protected]>
---
 lib/bootconfig.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 6b899e24189c..69486bd56fea 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -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)
@@ -982,7 +982,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)
-- 
2.34.1


Reply via email to