summaryrefslogtreecommitdiff
path: root/drivers/core/root.c
diff options
context:
space:
mode:
authorRasmus Villemoes <[email protected]>2026-04-21 09:54:38 +0200
committerTom Rini <[email protected]>2026-05-12 15:38:00 -0600
commit4ef201e607ebed2432ee929446e3fb9b57c53a54 (patch)
treee619ebada0b2c2595fc52f4a88acc94b3a13b696 /drivers/core/root.c
parent11168813bf9c088e1fce8a96f4b493ee815c966b (diff)
drivers/core: use memdup() instead of malloc()+memcpy()
Use memdup() instead of open-coding it. In the dm_setup_inst() case, there was never any reason to use calloc(), as the whole allocation is definitely initialized via the immediately following memcpy(). Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Rasmus Villemoes <[email protected]>
Diffstat (limited to 'drivers/core/root.c')
-rw-r--r--drivers/core/root.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/core/root.c b/drivers/core/root.c
index d43645f34dd..1f32f33b295 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -81,10 +81,9 @@ static int dm_setup_inst(void)
/* Now allocate space for the priv/plat data, and copy it in */
size = __priv_data_end - __priv_data_start;
- base = calloc(1, size);
+ base = memdup(__priv_data_start, size);
if (!base)
return log_msg_ret("priv", -ENOMEM);
- memcpy(base, __priv_data_start, size);
gd_set_dm_priv_base(base);
}