Skip to contentSkip to conversation

mmc: mv_sdhci: zero out sdhci_host structure

PATCH Superseded Matt Pelland 2 participants 3 messages Mar 27, 2018 – Apr 16, 2018 MMC, SD and SDIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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, 2 insertions(+)
drivers/mmc/mv_sdhci.c +2 -0
index 69aa87babe..afc03f75a0 100644
@@ -74,6 +74,8 @@ int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
 		return -ENOMEM;
 	}
 
+	memset(host, 0, sizeof(struct sdhci_host));
+
 	host->name = MVSDH_NAME;
 	host->ioaddr = (void *)regbase;
 	host->quirks = quirks;
Signature · 1 line
2.14.3
#1 lore raw

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

Hi Matt,

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, 2 insertions(+)
drivers/mmc/mv_sdhci.c +0 -0
index 69aa87babe..afc03f75a0 100644

drivers/mmc/mv_sdhci.c int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks) · line 81

Quoted 8 lines
drivers/mmc/mv_sdhci.c +2 -0
@@ -74,6 +74,8 @@ int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
  		return -ENOMEM;
  	}
 
+	memset(host, 0, sizeof(struct sdhci_host));
+
  	host->name = MVSDH_NAME;
  	host->ioaddr = (void *)regbase;
  	host->quirks = quirks;

Thanks for finding this. But please use calloc() instead of malloc() and the memset can be dropped.

Thanks,
Stefan

#2 lore raw

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

Quoted 21 lines · Stefan Roese

Hi Matt,

Quoted 18 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, 2 insertions(+)
drivers/mmc/mv_sdhci.c +1 -0
index 69aa87babe..afc03f75a0 100644
@@ -74,6 +74,8 @@ int mv_sdh_init(unsigned long regbase, u32 max_clk, 
 u32 min_clk, u32 quirks)
           return -ENOMEM;
       }
+    memset(host, 0, sizeof(struct sdhci_host));
Quoted 8 lines

drivers/mmc/mv_sdhci.c int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks) · line 81

Quoted 5 lines
drivers/mmc/mv_sdhci.c +1 -0
+
       host->name = MVSDH_NAME;
       host->ioaddr = (void *)regbase;
       host->quirks = quirks;

Thanks for finding this. But please use calloc() instead of malloc() and the memset can be dropped.

Any chance for a respin of v2 with calloc() soon (for the upcoming release)?

Thanks,
Stefan