Skip to contentSkip to conversation

mmc: mv_sdhci: zero out sdhci_host structure

PATCH New Matt Pelland 2 participants 3 messages Apr 16, 2018 – Apr 17, 2018 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mmc: mv_sdhci: zero out sdhci_host structure

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.

---
 drivers/mmc/mv_sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/mv_sdhci.c +1 -1
index 69aa87babe..0ed0d38c90 100644
@@ -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;
Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 1/1 mmc: mv_sdhci: zero out sdhci_host structure

Quoted 15 lines · Matt Pelland

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.

---
  drivers/mmc/mv_sdhci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/mv_sdhci.c +0 -0
index 69aa87babe..0ed0d38c90 100644

drivers/mmc/mv_sdhci.c static char *MVSDH_NAME = "mv_sdh"; · line 74

Quoted 8 lines
drivers/mmc/mv_sdhci.c +1 -1
@@ -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:

Thanks,
Stefan

#2 lore raw

PATCH v2 1/1 mmc: mv_sdhci: zero out sdhci_host structure

Quoted 28 lines · Stefan Roese
Quoted 15 lines · Matt Pelland

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.

---
  drivers/mmc/mv_sdhci.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/mv_sdhci.c +0 -0
index 69aa87babe..0ed0d38c90 100644
@@ -68,7 +68,7 @@ static char *MVSDH_NAME = "mv_sdh";

  int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32

Quoted 9 lines

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:

Quoted 1 line

Applied to u-boot-marvell/master.

Thanks,
Stefan