mmc: bcm2835_sdhci: Use calloc to allocate bcm2835_sdhci_host
Subsystems (3)
PATCH 1/1 mmc: bcm2835_sdhci: Use calloc to allocate bcm2835_sdhci_host
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.
--- drivers/mmc/bcm2835_sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/bcm2835_sdhci.c +2 -2
@@ -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 ; }
Signature · 1 line
2.3.5
PATCH 1/1 mmc: bcm2835_sdhci: Use calloc to allocate bcm2835_sdhci_host
Any feedback on this?
Best regards,
Alexander
On Friday 17 April 2015, 17:33:17 wrote Alexander Stein:
Quoted 27 lines
We need to clear the allocated memory explicitly as the included struct
sdhci_hosthas 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 <[email protected]>--- drivers/mmc/bcm2835_sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/bcm2835_sdhci.c +2
-2@@ -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 ; }
Pantelis Antoniou
AppliedPATCH 1/1 mmc: bcm2835_sdhci: Use calloc to allocate bcm2835_sdhci_host
In reply to Alexander SteinHi Alexander,
Quoted 31 lines · Alexander Stein
We need to clear the allocated memory explicitly as the included struct
sdhci_hosthas 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 <[email protected]>---
drivers/mmc/bcm2835_sdhci.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/bcm2835_sdhci.c +2
-2@@ -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 ; }Signature · 1 line
2.3.5
Applied, Thanks.
? Pantelis