diff mbox series

[U-Boot,v2] mmc: mv_sdhci: zero out sdhci_host structure

Message ID 20180416140818.18013-1-mpelland@starry.com
State Accepted
Commit ca4e7d674ee6931c7a4effd697e644d7646cfac0
Delegated to: Stefan Roese
Headers show
Series [U-Boot,v2] mmc: mv_sdhci: zero out sdhci_host structure | expand

Commit Message

Matt Pelland April 16, 2018, 2:08 p.m. UTC
The mv_sdhci driver was not zeroing the sdhci_host structure it
allocates causing random access violations in parts of the mmc core
where the "ops" member pointers are checked and called if not NULL.

Signed-off-by: Matt Pelland <mpelland@starry.com>
---
 drivers/mmc/mv_sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Roese April 16, 2018, 3:13 p.m. UTC | #1
On 16.04.2018 16:08, Matt Pelland wrote:
> The mv_sdhci driver was not zeroing the sdhci_host structure it
> allocates causing random access violations in parts of the mmc core
> where the "ops" member pointers are checked and called if not NULL.
> 
> Signed-off-by: Matt Pelland <mpelland@starry.com>
> ---
>   drivers/mmc/mv_sdhci.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c
> index 69aa87babe..0ed0d38c90 100644
> --- a/drivers/mmc/mv_sdhci.c
> +++ b/drivers/mmc/mv_sdhci.c
> @@ -68,7 +68,7 @@ static char *MVSDH_NAME = "mv_sdh";
>   int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
>   {
>   	struct sdhci_host *host = NULL;
> -	host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
> +	host = calloc(1, sizeof(*host));
>   	if (!host) {
>   		printf("sdh_host malloc fail!\n");
>   		return -ENOMEM;
> 

Looks good, so:

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
Stefan Roese April 17, 2018, 8:50 a.m. UTC | #2
On 16.04.2018 17:13, Stefan Roese wrote:
> On 16.04.2018 16:08, Matt Pelland wrote:
>> The mv_sdhci driver was not zeroing the sdhci_host structure it
>> allocates causing random access violations in parts of the mmc core
>> where the "ops" member pointers are checked and called if not NULL.
>>
>> Signed-off-by: Matt Pelland <mpelland@starry.com>
>> ---
>>   drivers/mmc/mv_sdhci.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c
>> index 69aa87babe..0ed0d38c90 100644
>> --- a/drivers/mmc/mv_sdhci.c
>> +++ b/drivers/mmc/mv_sdhci.c
>> @@ -68,7 +68,7 @@ static char *MVSDH_NAME = "mv_sdh";
>>   int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 
>> quirks)
>>   {
>>       struct sdhci_host *host = NULL;
>> -    host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
>> +    host = calloc(1, sizeof(*host));
>>       if (!host) {
>>           printf("sdh_host malloc fail!\n");
>>           return -ENOMEM;
>>
> 
> Looks good, so:
> 
> Reviewed-by: Stefan Roese <sr@denx.de>

Applied to u-boot-marvell/master.

Thanks,
Stefan
diff mbox series

Patch

diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c
index 69aa87babe..0ed0d38c90 100644
--- a/drivers/mmc/mv_sdhci.c
+++ b/drivers/mmc/mv_sdhci.c
@@ -68,7 +68,7 @@  static char *MVSDH_NAME = "mv_sdh";
 int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
 {
 	struct sdhci_host *host = NULL;
-	host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
+	host = calloc(1, sizeof(*host));
 	if (!host) {
 		printf("sdh_host malloc fail!\n");
 		return -ENOMEM;