diff mbox series

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

Message ID 20220330165446.438925-3-seanga2@gmail.com
State Changes Requested
Delegated to: Jaehoon Chung
Headers show
Series mmc: sandbox: Some small fixes | expand

Commit Message

Sean Anderson March 30, 2022, 4:54 p.m. UTC
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@gmail.com>
---

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

Comments

Jaehoon Chung April 22, 2022, 12:03 p.m. UTC | #1
On 3/31/22 01:54, Sean Anderson wrote:
> 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@gmail.com>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>


Best Regards,
Jaehoon Chung

> ---
> 
>  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);
diff mbox series

Patch

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);