[PATCH 2/4] mmc: sandbox: Initialize backing buffer

Sean Anderson seanga2 at gmail.com
Wed Mar 30 18:54:44 CEST 2022


Private data is initialized to all zeros by DM. Malloc does not do this.
Initialize it. This fixes partition detection logic from trying to detect
partitions in uninitialized memory.

Fixes: 0bf61aced2 ("sandbox: mmc: Support a backing file")
Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---

 drivers/mmc/sandbox_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
index 35159451e1..60a6be0add 100644
--- a/drivers/mmc/sandbox_mmc.c
+++ b/drivers/mmc/sandbox_mmc.c
@@ -178,7 +178,7 @@ static int sandbox_mmc_probe(struct udevice *dev)
 		priv->csize = 0;
 		priv->size = (priv->csize + 1) * SIZE_MULTIPLE; /* 1 MiB */
 
-		priv->buf = malloc(priv->size);
+		priv->buf = calloc(1, priv->size);
 		if (!priv->buf) {
 			log_err("%s: Not enough memory (%x bytes)\n",
 				dev->name, priv->size);
-- 
2.35.1



More information about the U-Boot mailing list