]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mmc: bcm2835_sdhci: Use calloc to allocate bcm2835_sdhci_host
authorAlexander Stein <alexanders83@web.de>
Fri, 17 Apr 2015 15:33:17 +0000 (17:33 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 20:37:10 +0000 (22:37 +0200)
We need to clear the allocated memory explicitly as the included
struct sdhci_host has function pointers. Those are compared to NULL to
test if this (optional) feature is supported. Leaving them undefined let
u-boot jump to arbitrary memory.

Signed-off-by: Alexander Stein <alexanders83@web.de>
drivers/mmc/bcm2835_sdhci.c

index 4ec2968ece203db94bfb59539ce531cb4775150e..56775131f03379c3b2b2282679e4c3fac456a7dc 100644 (file)
@@ -154,9 +154,9 @@ int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq)
        struct bcm2835_sdhci_host *bcm_host;
        struct sdhci_host *host;
 
-       bcm_host = malloc(sizeof(*bcm_host));
+       bcm_host = calloc(1, sizeof(*bcm_host));
        if (!bcm_host) {
-               printf("sdhci_host malloc fail!\n");
+               printf("sdhci_host calloc fail!\n");
                return 1;
        }