[PATCH v2 09/71] sandbox: mmc: Start off with a zeroed file

Simon Glass sjg at chromium.org
Sun Jan 8 03:49:45 CET 2023


When running multiple tests the mmc emulator calls malloc() to obtain the
memory for its disk image. Since the memory is not cleared, it is possible
that it happens to contain a partition table.

The dm_test_part() test (for one) relies on mmc0 being empty on startup.
Zero the memory to ensure that it is.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 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 ba79a5565c3..0ba7940a4db 100644
--- a/drivers/mmc/sandbox_mmc.c
+++ b/drivers/mmc/sandbox_mmc.c
@@ -183,7 +183,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.39.0.314.g84b9a713c41-goog



More information about the U-Boot-Custodians mailing list