[U-Boot] [PATCH] driver: fsl-mc: memset pointers after malloc
Prabhakar Kushwaha
prabhakar.kushwaha at nxp.com
Fri Oct 6 11:05:37 UTC 2017
Memory allocated via malloc is not guaranteed to be zeroized.
So explicitly memset the memory allocated via malloc.
Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha at nxp.com>
---
drivers/net/fsl-mc/mc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 12dbcd8..c03d68f 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -730,6 +730,7 @@ int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr)
printf(" No memory: malloc() failed\n");
return -ENOMEM;
}
+ memset(root_mc_io, 0, sizeof(struct fsl_mc_io));
root_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(portal_id);
debug("Checking access to MC portal of root DPRC container (portal_id %d, portal physical addr %p)\n",
@@ -885,6 +886,7 @@ static int dpio_init(void)
err = -ENOMEM;
goto err_malloc;
}
+ memset(dflt_dpio, 0, sizeof(struct fsl_dpio_obj));
dpio_cfg.channel_mode = DPIO_LOCAL_CHANNEL;
dpio_cfg.num_priorities = 8;
@@ -1036,6 +1038,7 @@ static int dprc_init(void)
printf(" No memory: malloc() failed\n");
goto err_malloc;
}
+ memset(dflt_mc_io, 0, sizeof(struct fsl_mc_io));
child_portal_id = MC_PORTAL_OFFSET_TO_PORTAL_ID(mc_portal_offset);
dflt_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(child_portal_id);
@@ -1116,6 +1119,7 @@ static int dpbp_init(void)
err = -ENOMEM;
goto err_malloc;
}
+ memset(dflt_dpbp, 0, sizeof(struct fsl_dpbp_obj));
dpbp_cfg.options = 512;
@@ -1212,6 +1216,7 @@ static int dpni_init(void)
err = -ENOMEM;
goto err_malloc;
}
+ memset(dflt_dpni, 0, sizeof(struct fsl_dpni_obj));
memset(&dpni_extended_cfg, 0, sizeof(dpni_extended_cfg));
err = dpni_prepare_extended_cfg(&dpni_extended_cfg, &ext_cfg_buf[0]);
--
2.7.4
More information about the U-Boot
mailing list